
obj/user/ls:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 63 03 00 00       	call   800394 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800040 <usage>:
	printf("\n");
}

void
usage(void)
{
  800040:	55                   	push   %ebp
  800041:	89 e5                	mov    %esp,%ebp
  800043:	83 ec 18             	sub    $0x18,%esp
	printf("usage: ls [-dFl] [file...]\n");
  800046:	c7 04 24 80 2c 80 00 	movl   $0x802c80,(%esp)
  80004d:	e8 a5 1d 00 00       	call   801df7 <printf>
	exit();
  800052:	e8 8d 03 00 00       	call   8003e4 <exit>
}
  800057:	c9                   	leave  
  800058:	c3                   	ret    

00800059 <ls1>:
		panic("error reading directory %s: %e", path, n);
}

void
ls1(const char *prefix, bool isdir, off_t size, const char *name)
{
  800059:	55                   	push   %ebp
  80005a:	89 e5                	mov    %esp,%ebp
  80005c:	56                   	push   %esi
  80005d:	53                   	push   %ebx
  80005e:	83 ec 10             	sub    $0x10,%esp
  800061:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800064:	8b 75 0c             	mov    0xc(%ebp),%esi
	char *sep;

	if(flag['l'])
  800067:	83 3d 30 72 80 00 00 	cmpl   $0x0,0x807230
  80006e:	74 22                	je     800092 <ls1+0x39>
		printf("%11d %c ", size, isdir ? 'd' : '-');
  800070:	83 fe 01             	cmp    $0x1,%esi
  800073:	19 c0                	sbb    %eax,%eax
  800075:	83 e0 c9             	and    $0xffffffc9,%eax
  800078:	83 c0 64             	add    $0x64,%eax
  80007b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80007f:	8b 45 10             	mov    0x10(%ebp),%eax
  800082:	89 44 24 04          	mov    %eax,0x4(%esp)
  800086:	c7 04 24 9c 2c 80 00 	movl   $0x802c9c,(%esp)
  80008d:	e8 65 1d 00 00       	call   801df7 <printf>
	if(prefix) {
  800092:	85 db                	test   %ebx,%ebx
  800094:	74 34                	je     8000ca <ls1+0x71>
		if (prefix[0] && prefix[strlen(prefix)-1] != '/')
  800096:	80 3b 00             	cmpb   $0x0,(%ebx)
  800099:	74 16                	je     8000b1 <ls1+0x58>
  80009b:	89 1c 24             	mov    %ebx,(%esp)
  80009e:	66 90                	xchg   %ax,%ax
  8000a0:	e8 ab 0a 00 00       	call   800b50 <strlen>
  8000a5:	ba a5 2c 80 00       	mov    $0x802ca5,%edx
  8000aa:	80 7c 18 ff 2f       	cmpb   $0x2f,-0x1(%eax,%ebx,1)
  8000af:	75 05                	jne    8000b6 <ls1+0x5d>
  8000b1:	ba 9b 2c 80 00       	mov    $0x802c9b,%edx
			sep = "/";
		else
			sep = "";
		printf("%s%s", prefix, sep);
  8000b6:	89 54 24 08          	mov    %edx,0x8(%esp)
  8000ba:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8000be:	c7 04 24 a7 2c 80 00 	movl   $0x802ca7,(%esp)
  8000c5:	e8 2d 1d 00 00       	call   801df7 <printf>
	}
	printf("%s", name);
  8000ca:	8b 45 14             	mov    0x14(%ebp),%eax
  8000cd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000d1:	c7 04 24 32 31 80 00 	movl   $0x803132,(%esp)
  8000d8:	e8 1a 1d 00 00       	call   801df7 <printf>
	if(flag['F'] && isdir)
  8000dd:	83 3d 98 71 80 00 00 	cmpl   $0x0,0x807198
  8000e4:	74 10                	je     8000f6 <ls1+0x9d>
  8000e6:	85 f6                	test   %esi,%esi
  8000e8:	74 0c                	je     8000f6 <ls1+0x9d>
		printf("/");
  8000ea:	c7 04 24 a5 2c 80 00 	movl   $0x802ca5,(%esp)
  8000f1:	e8 01 1d 00 00       	call   801df7 <printf>
	printf("\n");
  8000f6:	c7 04 24 9a 2c 80 00 	movl   $0x802c9a,(%esp)
  8000fd:	e8 f5 1c 00 00       	call   801df7 <printf>
}
  800102:	83 c4 10             	add    $0x10,%esp
  800105:	5b                   	pop    %ebx
  800106:	5e                   	pop    %esi
  800107:	5d                   	pop    %ebp
  800108:	c3                   	ret    

00800109 <lsdir>:
		ls1(0, st.st_isdir, st.st_size, path);
}

void
lsdir(const char *path, const char *prefix)
{
  800109:	55                   	push   %ebp
  80010a:	89 e5                	mov    %esp,%ebp
  80010c:	57                   	push   %edi
  80010d:	56                   	push   %esi
  80010e:	53                   	push   %ebx
  80010f:	81 ec 2c 01 00 00    	sub    $0x12c,%esp
  800115:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int fd, n;
	struct File f;

	if ((fd = open(path, O_RDONLY)) < 0)
  800118:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80011f:	00 
  800120:	8b 45 08             	mov    0x8(%ebp),%eax
  800123:	89 04 24             	mov    %eax,(%esp)
  800126:	e8 81 1b 00 00       	call   801cac <open>
  80012b:	89 c6                	mov    %eax,%esi
  80012d:	85 c0                	test   %eax,%eax
  80012f:	79 59                	jns    80018a <lsdir+0x81>
		panic("open %s: %e", path, fd);
  800131:	89 44 24 10          	mov    %eax,0x10(%esp)
  800135:	8b 45 08             	mov    0x8(%ebp),%eax
  800138:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80013c:	c7 44 24 08 ac 2c 80 	movl   $0x802cac,0x8(%esp)
  800143:	00 
  800144:	c7 44 24 04 1d 00 00 	movl   $0x1d,0x4(%esp)
  80014b:	00 
  80014c:	c7 04 24 b8 2c 80 00 	movl   $0x802cb8,(%esp)
  800153:	e8 a8 02 00 00       	call   800400 <_panic>
	while ((n = readn(fd, &f, sizeof f)) == sizeof f)
		if (f.f_name[0])
  800158:	80 bd e8 fe ff ff 00 	cmpb   $0x0,-0x118(%ebp)
  80015f:	74 2f                	je     800190 <lsdir+0x87>
			ls1(prefix, f.f_type==FTYPE_DIR, f.f_size, f.f_name);
  800161:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800165:	8b 85 68 ff ff ff    	mov    -0x98(%ebp),%eax
  80016b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80016f:	83 bd 6c ff ff ff 01 	cmpl   $0x1,-0x94(%ebp)
  800176:	0f 94 c0             	sete   %al
  800179:	0f b6 c0             	movzbl %al,%eax
  80017c:	89 44 24 04          	mov    %eax,0x4(%esp)
  800180:	89 3c 24             	mov    %edi,(%esp)
  800183:	e8 d1 fe ff ff       	call   800059 <ls1>
  800188:	eb 06                	jmp    800190 <lsdir+0x87>
	int fd, n;
	struct File f;

	if ((fd = open(path, O_RDONLY)) < 0)
		panic("open %s: %e", path, fd);
	while ((n = readn(fd, &f, sizeof f)) == sizeof f)
  80018a:	8d 9d e8 fe ff ff    	lea    -0x118(%ebp),%ebx
  800190:	c7 44 24 08 00 01 00 	movl   $0x100,0x8(%esp)
  800197:	00 
  800198:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80019c:	89 34 24             	mov    %esi,(%esp)
  80019f:	e8 5d 16 00 00       	call   801801 <readn>
  8001a4:	3d 00 01 00 00       	cmp    $0x100,%eax
  8001a9:	74 ad                	je     800158 <lsdir+0x4f>
		if (f.f_name[0])
			ls1(prefix, f.f_type==FTYPE_DIR, f.f_size, f.f_name);
	if (n > 0)
  8001ab:	85 c0                	test   %eax,%eax
  8001ad:	7e 23                	jle    8001d2 <lsdir+0xc9>
		panic("short read in directory %s", path);
  8001af:	8b 45 08             	mov    0x8(%ebp),%eax
  8001b2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001b6:	c7 44 24 08 c2 2c 80 	movl   $0x802cc2,0x8(%esp)
  8001bd:	00 
  8001be:	c7 44 24 04 22 00 00 	movl   $0x22,0x4(%esp)
  8001c5:	00 
  8001c6:	c7 04 24 b8 2c 80 00 	movl   $0x802cb8,(%esp)
  8001cd:	e8 2e 02 00 00       	call   800400 <_panic>
	if (n < 0)
  8001d2:	85 c0                	test   %eax,%eax
  8001d4:	79 27                	jns    8001fd <lsdir+0xf4>
		panic("error reading directory %s: %e", path, n);
  8001d6:	89 44 24 10          	mov    %eax,0x10(%esp)
  8001da:	8b 45 08             	mov    0x8(%ebp),%eax
  8001dd:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8001e1:	c7 44 24 08 ec 2c 80 	movl   $0x802cec,0x8(%esp)
  8001e8:	00 
  8001e9:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  8001f0:	00 
  8001f1:	c7 04 24 b8 2c 80 00 	movl   $0x802cb8,(%esp)
  8001f8:	e8 03 02 00 00       	call   800400 <_panic>
}
  8001fd:	81 c4 2c 01 00 00    	add    $0x12c,%esp
  800203:	5b                   	pop    %ebx
  800204:	5e                   	pop    %esi
  800205:	5f                   	pop    %edi
  800206:	5d                   	pop    %ebp
  800207:	c3                   	ret    

00800208 <ls>:
void lsdir(const char*, const char*);
void ls1(const char*, bool, off_t, const char*);

void
ls(const char *path, const char *prefix)
{
  800208:	55                   	push   %ebp
  800209:	89 e5                	mov    %esp,%ebp
  80020b:	53                   	push   %ebx
  80020c:	81 ec b4 00 00 00    	sub    $0xb4,%esp
  800212:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Stat st;

	if ((r = stat(path, &st)) < 0)
  800215:	8d 85 6c ff ff ff    	lea    -0x94(%ebp),%eax
  80021b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80021f:	89 1c 24             	mov    %ebx,(%esp)
  800222:	e8 e6 16 00 00       	call   80190d <stat>
  800227:	85 c0                	test   %eax,%eax
  800229:	79 24                	jns    80024f <ls+0x47>
		panic("stat %s: %e", path, r);
  80022b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80022f:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800233:	c7 44 24 08 dd 2c 80 	movl   $0x802cdd,0x8(%esp)
  80023a:	00 
  80023b:	c7 44 24 04 0f 00 00 	movl   $0xf,0x4(%esp)
  800242:	00 
  800243:	c7 04 24 b8 2c 80 00 	movl   $0x802cb8,(%esp)
  80024a:	e8 b1 01 00 00       	call   800400 <_panic>
	if (st.st_isdir && !flag['d'])
  80024f:	8b 45 f0             	mov    -0x10(%ebp),%eax
  800252:	85 c0                	test   %eax,%eax
  800254:	74 1a                	je     800270 <ls+0x68>
  800256:	83 3d 10 72 80 00 00 	cmpl   $0x0,0x807210
  80025d:	75 11                	jne    800270 <ls+0x68>
		lsdir(path, prefix);
  80025f:	8b 45 0c             	mov    0xc(%ebp),%eax
  800262:	89 44 24 04          	mov    %eax,0x4(%esp)
  800266:	89 1c 24             	mov    %ebx,(%esp)
  800269:	e8 9b fe ff ff       	call   800109 <lsdir>
	int r;
	struct Stat st;

	if ((r = stat(path, &st)) < 0)
		panic("stat %s: %e", path, r);
	if (st.st_isdir && !flag['d'])
  80026e:	eb 1b                	jmp    80028b <ls+0x83>
		lsdir(path, prefix);
	else
		ls1(0, st.st_isdir, st.st_size, path);
  800270:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800274:	8b 55 ec             	mov    -0x14(%ebp),%edx
  800277:	89 54 24 08          	mov    %edx,0x8(%esp)
  80027b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80027f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  800286:	e8 ce fd ff ff       	call   800059 <ls1>
}
  80028b:	81 c4 b4 00 00 00    	add    $0xb4,%esp
  800291:	5b                   	pop    %ebx
  800292:	5d                   	pop    %ebp
  800293:	c3                   	ret    

00800294 <umain>:
	exit();
}

void
umain(int argc, char **argv)
{
  800294:	55                   	push   %ebp
  800295:	89 e5                	mov    %esp,%ebp
  800297:	57                   	push   %edi
  800298:	56                   	push   %esi
  800299:	53                   	push   %ebx
  80029a:	83 ec 2c             	sub    $0x2c,%esp
  80029d:	8b 45 0c             	mov    0xc(%ebp),%eax
	int i;

	ARGBEGIN{
  8002a0:	85 c0                	test   %eax,%eax
  8002a2:	8d 55 08             	lea    0x8(%ebp),%edx
  8002a5:	0f 44 c2             	cmove  %edx,%eax
  8002a8:	83 3d 84 74 80 00 00 	cmpl   $0x0,0x807484
  8002af:	75 08                	jne    8002b9 <umain+0x25>
  8002b1:	8b 10                	mov    (%eax),%edx
  8002b3:	89 15 84 74 80 00    	mov    %edx,0x807484
  8002b9:	83 c0 04             	add    $0x4,%eax
  8002bc:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  8002bf:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8002c3:	8b 30                	mov    (%eax),%esi
  8002c5:	85 f6                	test   %esi,%esi
  8002c7:	74 7f                	je     800348 <umain+0xb4>
  8002c9:	80 3e 2d             	cmpb   $0x2d,(%esi)
  8002cc:	75 7a                	jne    800348 <umain+0xb4>
  8002ce:	83 c6 01             	add    $0x1,%esi
  8002d1:	0f b6 06             	movzbl (%esi),%eax
  8002d4:	84 c0                	test   %al,%al
  8002d6:	74 70                	je     800348 <umain+0xb4>
	default:
		usage();
	case 'd':
	case 'F':
	case 'l':
		flag[(uint8_t)ARGC()]++;
  8002d8:	bf 80 70 80 00       	mov    $0x807080,%edi
void
umain(int argc, char **argv)
{
	int i;

	ARGBEGIN{
  8002dd:	3c 2d                	cmp    $0x2d,%al
  8002df:	74 0c                	je     8002ed <umain+0x59>
  8002e1:	0f b6 1e             	movzbl (%esi),%ebx
  8002e4:	84 db                	test   %bl,%bl
  8002e6:	74 40                	je     800328 <umain+0x94>
  8002e8:	83 c6 01             	add    $0x1,%esi
  8002eb:	eb 10                	jmp    8002fd <umain+0x69>
  8002ed:	80 7e 01 00          	cmpb   $0x0,0x1(%esi)
  8002f1:	75 ee                	jne    8002e1 <umain+0x4d>
  8002f3:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  8002f7:	83 45 e4 04          	addl   $0x4,-0x1c(%ebp)
  8002fb:	eb 4b                	jmp    800348 <umain+0xb4>
  8002fd:	80 fb 64             	cmp    $0x64,%bl
  800300:	74 13                	je     800315 <umain+0x81>
  800302:	80 fb 6c             	cmp    $0x6c,%bl
  800305:	74 0e                	je     800315 <umain+0x81>
  800307:	80 fb 46             	cmp    $0x46,%bl
  80030a:	74 09                	je     800315 <umain+0x81>
	default:
		usage();
  80030c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800310:	e8 2b fd ff ff       	call   800040 <usage>
	case 'd':
	case 'F':
	case 'l':
		flag[(uint8_t)ARGC()]++;
  800315:	0f b6 db             	movzbl %bl,%ebx
  800318:	83 04 9f 01          	addl   $0x1,(%edi,%ebx,4)
void
umain(int argc, char **argv)
{
	int i;

	ARGBEGIN{
  80031c:	0f b6 1e             	movzbl (%esi),%ebx
  80031f:	84 db                	test   %bl,%bl
  800321:	74 05                	je     800328 <umain+0x94>
  800323:	83 c6 01             	add    $0x1,%esi
  800326:	eb d5                	jmp    8002fd <umain+0x69>
  800328:	83 6d 08 01          	subl   $0x1,0x8(%ebp)
  80032c:	83 45 e4 04          	addl   $0x4,-0x1c(%ebp)
  800330:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  800333:	8b 30                	mov    (%eax),%esi
  800335:	85 f6                	test   %esi,%esi
  800337:	74 0f                	je     800348 <umain+0xb4>
  800339:	80 3e 2d             	cmpb   $0x2d,(%esi)
  80033c:	75 0a                	jne    800348 <umain+0xb4>
  80033e:	83 c6 01             	add    $0x1,%esi
  800341:	0f b6 06             	movzbl (%esi),%eax
  800344:	84 c0                	test   %al,%al
  800346:	75 95                	jne    8002dd <umain+0x49>
	case 'l':
		flag[(uint8_t)ARGC()]++;
		break;
	}ARGEND

	if (argc == 0)
  800348:	8b 45 08             	mov    0x8(%ebp),%eax
  80034b:	85 c0                	test   %eax,%eax
  80034d:	74 0b                	je     80035a <umain+0xc6>
		ls("/", "");
  80034f:	bb 00 00 00 00       	mov    $0x0,%ebx
	else {
		for (i=0; i<argc; i++)
  800354:	85 c0                	test   %eax,%eax
  800356:	7f 18                	jg     800370 <umain+0xdc>
  800358:	eb 30                	jmp    80038a <umain+0xf6>
		flag[(uint8_t)ARGC()]++;
		break;
	}ARGEND

	if (argc == 0)
		ls("/", "");
  80035a:	c7 44 24 04 9b 2c 80 	movl   $0x802c9b,0x4(%esp)
  800361:	00 
  800362:	c7 04 24 a5 2c 80 00 	movl   $0x802ca5,(%esp)
  800369:	e8 9a fe ff ff       	call   800208 <ls>
  80036e:	eb 1a                	jmp    80038a <umain+0xf6>
	else {
		for (i=0; i<argc; i++)
			ls(argv[i], argv[i]);
  800370:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800373:	8b 04 9a             	mov    (%edx,%ebx,4),%eax
  800376:	89 44 24 04          	mov    %eax,0x4(%esp)
  80037a:	89 04 24             	mov    %eax,(%esp)
  80037d:	e8 86 fe ff ff       	call   800208 <ls>
	}ARGEND

	if (argc == 0)
		ls("/", "");
	else {
		for (i=0; i<argc; i++)
  800382:	83 c3 01             	add    $0x1,%ebx
  800385:	39 5d 08             	cmp    %ebx,0x8(%ebp)
  800388:	7f e6                	jg     800370 <umain+0xdc>
			ls(argv[i], argv[i]);
	}
}
  80038a:	83 c4 2c             	add    $0x2c,%esp
  80038d:	5b                   	pop    %ebx
  80038e:	5e                   	pop    %esi
  80038f:	5f                   	pop    %edi
  800390:	5d                   	pop    %ebp
  800391:	c3                   	ret    
	...

00800394 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800394:	55                   	push   %ebp
  800395:	89 e5                	mov    %esp,%ebp
  800397:	83 ec 18             	sub    $0x18,%esp
  80039a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80039d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8003a0:	8b 75 08             	mov    0x8(%ebp),%esi
  8003a3:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  8003a6:	e8 de 0f 00 00       	call   801389 <sys_getenvid>
	env = &envs [ENVX(envid)];
  8003ab:	25 ff 03 00 00       	and    $0x3ff,%eax
  8003b0:	6b c0 7c             	imul   $0x7c,%eax,%eax
  8003b3:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  8003b8:	a3 80 74 80 00       	mov    %eax,0x807480

	// save the name of the program so that panic() can use it
	if (argc > 0)
  8003bd:	85 f6                	test   %esi,%esi
  8003bf:	7e 07                	jle    8003c8 <libmain+0x34>
		binaryname = argv[0];
  8003c1:	8b 03                	mov    (%ebx),%eax
  8003c3:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  8003c8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8003cc:	89 34 24             	mov    %esi,(%esp)
  8003cf:	e8 c0 fe ff ff       	call   800294 <umain>

	// exit gracefully
	exit();
  8003d4:	e8 0b 00 00 00       	call   8003e4 <exit>
}
  8003d9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8003dc:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8003df:	89 ec                	mov    %ebp,%esp
  8003e1:	5d                   	pop    %ebp
  8003e2:	c3                   	ret    
	...

008003e4 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8003e4:	55                   	push   %ebp
  8003e5:	89 e5                	mov    %esp,%ebp
  8003e7:	83 ec 18             	sub    $0x18,%esp
	close_all();
  8003ea:	e8 6a 15 00 00       	call   801959 <close_all>
	sys_env_destroy(0);
  8003ef:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8003f6:	e8 c2 0f 00 00       	call   8013bd <sys_env_destroy>
}
  8003fb:	c9                   	leave  
  8003fc:	c3                   	ret    
  8003fd:	00 00                	add    %al,(%eax)
	...

00800400 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  800400:	55                   	push   %ebp
  800401:	89 e5                	mov    %esp,%ebp
  800403:	53                   	push   %ebx
  800404:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  800407:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  80040a:	a1 84 74 80 00       	mov    0x807484,%eax
  80040f:	85 c0                	test   %eax,%eax
  800411:	74 10                	je     800423 <_panic+0x23>
		cprintf("%s: ", argv0);
  800413:	89 44 24 04          	mov    %eax,0x4(%esp)
  800417:	c7 04 24 22 2d 80 00 	movl   $0x802d22,(%esp)
  80041e:	e8 a2 00 00 00       	call   8004c5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800423:	8b 45 0c             	mov    0xc(%ebp),%eax
  800426:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80042a:	8b 45 08             	mov    0x8(%ebp),%eax
  80042d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800431:	a1 00 70 80 00       	mov    0x807000,%eax
  800436:	89 44 24 04          	mov    %eax,0x4(%esp)
  80043a:	c7 04 24 27 2d 80 00 	movl   $0x802d27,(%esp)
  800441:	e8 7f 00 00 00       	call   8004c5 <cprintf>
	vcprintf(fmt, ap);
  800446:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80044a:	8b 45 10             	mov    0x10(%ebp),%eax
  80044d:	89 04 24             	mov    %eax,(%esp)
  800450:	e8 0f 00 00 00       	call   800464 <vcprintf>
	cprintf("\n");
  800455:	c7 04 24 9a 2c 80 00 	movl   $0x802c9a,(%esp)
  80045c:	e8 64 00 00 00       	call   8004c5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800461:	cc                   	int3   
  800462:	eb fd                	jmp    800461 <_panic+0x61>

00800464 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800464:	55                   	push   %ebp
  800465:	89 e5                	mov    %esp,%ebp
  800467:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  80046d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800474:	00 00 00 
	b.cnt = 0;
  800477:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80047e:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800481:	8b 45 0c             	mov    0xc(%ebp),%eax
  800484:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800488:	8b 45 08             	mov    0x8(%ebp),%eax
  80048b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80048f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800495:	89 44 24 04          	mov    %eax,0x4(%esp)
  800499:	c7 04 24 df 04 80 00 	movl   $0x8004df,(%esp)
  8004a0:	e8 d8 01 00 00       	call   80067d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8004a5:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8004ab:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004af:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8004b5:	89 04 24             	mov    %eax,(%esp)
  8004b8:	e8 d3 0a 00 00       	call   800f90 <sys_cputs>

	return b.cnt;
}
  8004bd:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8004c3:	c9                   	leave  
  8004c4:	c3                   	ret    

008004c5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8004c5:	55                   	push   %ebp
  8004c6:	89 e5                	mov    %esp,%ebp
  8004c8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8004cb:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8004ce:	89 44 24 04          	mov    %eax,0x4(%esp)
  8004d2:	8b 45 08             	mov    0x8(%ebp),%eax
  8004d5:	89 04 24             	mov    %eax,(%esp)
  8004d8:	e8 87 ff ff ff       	call   800464 <vcprintf>
	va_end(ap);

	return cnt;
}
  8004dd:	c9                   	leave  
  8004de:	c3                   	ret    

008004df <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8004df:	55                   	push   %ebp
  8004e0:	89 e5                	mov    %esp,%ebp
  8004e2:	53                   	push   %ebx
  8004e3:	83 ec 14             	sub    $0x14,%esp
  8004e6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8004e9:	8b 03                	mov    (%ebx),%eax
  8004eb:	8b 55 08             	mov    0x8(%ebp),%edx
  8004ee:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8004f2:	83 c0 01             	add    $0x1,%eax
  8004f5:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8004f7:	3d ff 00 00 00       	cmp    $0xff,%eax
  8004fc:	75 19                	jne    800517 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  8004fe:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800505:	00 
  800506:	8d 43 08             	lea    0x8(%ebx),%eax
  800509:	89 04 24             	mov    %eax,(%esp)
  80050c:	e8 7f 0a 00 00       	call   800f90 <sys_cputs>
		b->idx = 0;
  800511:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  800517:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80051b:	83 c4 14             	add    $0x14,%esp
  80051e:	5b                   	pop    %ebx
  80051f:	5d                   	pop    %ebp
  800520:	c3                   	ret    
	...

00800530 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800530:	55                   	push   %ebp
  800531:	89 e5                	mov    %esp,%ebp
  800533:	57                   	push   %edi
  800534:	56                   	push   %esi
  800535:	53                   	push   %ebx
  800536:	83 ec 4c             	sub    $0x4c,%esp
  800539:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80053c:	89 d6                	mov    %edx,%esi
  80053e:	8b 45 08             	mov    0x8(%ebp),%eax
  800541:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800544:	8b 55 0c             	mov    0xc(%ebp),%edx
  800547:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80054a:	8b 45 10             	mov    0x10(%ebp),%eax
  80054d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800550:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800553:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800556:	b9 00 00 00 00       	mov    $0x0,%ecx
  80055b:	39 d1                	cmp    %edx,%ecx
  80055d:	72 15                	jb     800574 <printnum+0x44>
  80055f:	77 07                	ja     800568 <printnum+0x38>
  800561:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800564:	39 d0                	cmp    %edx,%eax
  800566:	76 0c                	jbe    800574 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800568:	83 eb 01             	sub    $0x1,%ebx
  80056b:	85 db                	test   %ebx,%ebx
  80056d:	8d 76 00             	lea    0x0(%esi),%esi
  800570:	7f 61                	jg     8005d3 <printnum+0xa3>
  800572:	eb 70                	jmp    8005e4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800574:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800578:	83 eb 01             	sub    $0x1,%ebx
  80057b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80057f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800583:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800587:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80058b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80058e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800591:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800594:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800598:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80059f:	00 
  8005a0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8005a3:	89 04 24             	mov    %eax,(%esp)
  8005a6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8005a9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8005ad:	e8 4e 24 00 00       	call   802a00 <__udivdi3>
  8005b2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8005b5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8005b8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8005bc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8005c0:	89 04 24             	mov    %eax,(%esp)
  8005c3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8005c7:	89 f2                	mov    %esi,%edx
  8005c9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8005cc:	e8 5f ff ff ff       	call   800530 <printnum>
  8005d1:	eb 11                	jmp    8005e4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8005d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005d7:	89 3c 24             	mov    %edi,(%esp)
  8005da:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8005dd:	83 eb 01             	sub    $0x1,%ebx
  8005e0:	85 db                	test   %ebx,%ebx
  8005e2:	7f ef                	jg     8005d3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8005e4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005e8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8005ec:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8005ef:	89 44 24 08          	mov    %eax,0x8(%esp)
  8005f3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8005fa:	00 
  8005fb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8005fe:	89 14 24             	mov    %edx,(%esp)
  800601:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800604:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800608:	e8 23 25 00 00       	call   802b30 <__umoddi3>
  80060d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800611:	0f be 80 43 2d 80 00 	movsbl 0x802d43(%eax),%eax
  800618:	89 04 24             	mov    %eax,(%esp)
  80061b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80061e:	83 c4 4c             	add    $0x4c,%esp
  800621:	5b                   	pop    %ebx
  800622:	5e                   	pop    %esi
  800623:	5f                   	pop    %edi
  800624:	5d                   	pop    %ebp
  800625:	c3                   	ret    

00800626 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800626:	55                   	push   %ebp
  800627:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800629:	83 fa 01             	cmp    $0x1,%edx
  80062c:	7e 0e                	jle    80063c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80062e:	8b 10                	mov    (%eax),%edx
  800630:	8d 4a 08             	lea    0x8(%edx),%ecx
  800633:	89 08                	mov    %ecx,(%eax)
  800635:	8b 02                	mov    (%edx),%eax
  800637:	8b 52 04             	mov    0x4(%edx),%edx
  80063a:	eb 22                	jmp    80065e <getuint+0x38>
	else if (lflag)
  80063c:	85 d2                	test   %edx,%edx
  80063e:	74 10                	je     800650 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800640:	8b 10                	mov    (%eax),%edx
  800642:	8d 4a 04             	lea    0x4(%edx),%ecx
  800645:	89 08                	mov    %ecx,(%eax)
  800647:	8b 02                	mov    (%edx),%eax
  800649:	ba 00 00 00 00       	mov    $0x0,%edx
  80064e:	eb 0e                	jmp    80065e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800650:	8b 10                	mov    (%eax),%edx
  800652:	8d 4a 04             	lea    0x4(%edx),%ecx
  800655:	89 08                	mov    %ecx,(%eax)
  800657:	8b 02                	mov    (%edx),%eax
  800659:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80065e:	5d                   	pop    %ebp
  80065f:	c3                   	ret    

00800660 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800660:	55                   	push   %ebp
  800661:	89 e5                	mov    %esp,%ebp
  800663:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800666:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80066a:	8b 10                	mov    (%eax),%edx
  80066c:	3b 50 04             	cmp    0x4(%eax),%edx
  80066f:	73 0a                	jae    80067b <sprintputch+0x1b>
		*b->buf++ = ch;
  800671:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800674:	88 0a                	mov    %cl,(%edx)
  800676:	83 c2 01             	add    $0x1,%edx
  800679:	89 10                	mov    %edx,(%eax)
}
  80067b:	5d                   	pop    %ebp
  80067c:	c3                   	ret    

0080067d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80067d:	55                   	push   %ebp
  80067e:	89 e5                	mov    %esp,%ebp
  800680:	57                   	push   %edi
  800681:	56                   	push   %esi
  800682:	53                   	push   %ebx
  800683:	83 ec 5c             	sub    $0x5c,%esp
  800686:	8b 7d 08             	mov    0x8(%ebp),%edi
  800689:	8b 75 0c             	mov    0xc(%ebp),%esi
  80068c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80068f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800696:	eb 11                	jmp    8006a9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800698:	85 c0                	test   %eax,%eax
  80069a:	0f 84 f9 03 00 00    	je     800a99 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8006a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006a4:	89 04 24             	mov    %eax,(%esp)
  8006a7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8006a9:	0f b6 03             	movzbl (%ebx),%eax
  8006ac:	83 c3 01             	add    $0x1,%ebx
  8006af:	83 f8 25             	cmp    $0x25,%eax
  8006b2:	75 e4                	jne    800698 <vprintfmt+0x1b>
  8006b4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8006b8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8006bf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8006c6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8006cd:	b9 00 00 00 00       	mov    $0x0,%ecx
  8006d2:	eb 06                	jmp    8006da <vprintfmt+0x5d>
  8006d4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8006d8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8006da:	0f b6 13             	movzbl (%ebx),%edx
  8006dd:	0f b6 c2             	movzbl %dl,%eax
  8006e0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8006e3:	8d 43 01             	lea    0x1(%ebx),%eax
  8006e6:	83 ea 23             	sub    $0x23,%edx
  8006e9:	80 fa 55             	cmp    $0x55,%dl
  8006ec:	0f 87 8a 03 00 00    	ja     800a7c <vprintfmt+0x3ff>
  8006f2:	0f b6 d2             	movzbl %dl,%edx
  8006f5:	ff 24 95 80 2e 80 00 	jmp    *0x802e80(,%edx,4)
  8006fc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800700:	eb d6                	jmp    8006d8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800702:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800705:	83 ea 30             	sub    $0x30,%edx
  800708:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80070b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80070e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800711:	83 fb 09             	cmp    $0x9,%ebx
  800714:	77 54                	ja     80076a <vprintfmt+0xed>
  800716:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800719:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80071c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80071f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800722:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800726:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800729:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80072c:	83 fb 09             	cmp    $0x9,%ebx
  80072f:	76 eb                	jbe    80071c <vprintfmt+0x9f>
  800731:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800734:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800737:	eb 31                	jmp    80076a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800739:	8b 55 14             	mov    0x14(%ebp),%edx
  80073c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80073f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800742:	8b 12                	mov    (%edx),%edx
  800744:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800747:	eb 21                	jmp    80076a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800749:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80074d:	ba 00 00 00 00       	mov    $0x0,%edx
  800752:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800756:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800759:	e9 7a ff ff ff       	jmp    8006d8 <vprintfmt+0x5b>
  80075e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800765:	e9 6e ff ff ff       	jmp    8006d8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80076a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80076e:	0f 89 64 ff ff ff    	jns    8006d8 <vprintfmt+0x5b>
  800774:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800777:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80077a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80077d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800780:	e9 53 ff ff ff       	jmp    8006d8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800785:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800788:	e9 4b ff ff ff       	jmp    8006d8 <vprintfmt+0x5b>
  80078d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800790:	8b 45 14             	mov    0x14(%ebp),%eax
  800793:	8d 50 04             	lea    0x4(%eax),%edx
  800796:	89 55 14             	mov    %edx,0x14(%ebp)
  800799:	89 74 24 04          	mov    %esi,0x4(%esp)
  80079d:	8b 00                	mov    (%eax),%eax
  80079f:	89 04 24             	mov    %eax,(%esp)
  8007a2:	ff d7                	call   *%edi
  8007a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8007a7:	e9 fd fe ff ff       	jmp    8006a9 <vprintfmt+0x2c>
  8007ac:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8007af:	8b 45 14             	mov    0x14(%ebp),%eax
  8007b2:	8d 50 04             	lea    0x4(%eax),%edx
  8007b5:	89 55 14             	mov    %edx,0x14(%ebp)
  8007b8:	8b 00                	mov    (%eax),%eax
  8007ba:	89 c2                	mov    %eax,%edx
  8007bc:	c1 fa 1f             	sar    $0x1f,%edx
  8007bf:	31 d0                	xor    %edx,%eax
  8007c1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8007c3:	83 f8 12             	cmp    $0x12,%eax
  8007c6:	7f 0b                	jg     8007d3 <vprintfmt+0x156>
  8007c8:	8b 14 85 e0 2f 80 00 	mov    0x802fe0(,%eax,4),%edx
  8007cf:	85 d2                	test   %edx,%edx
  8007d1:	75 20                	jne    8007f3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8007d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8007d7:	c7 44 24 08 54 2d 80 	movl   $0x802d54,0x8(%esp)
  8007de:	00 
  8007df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007e3:	89 3c 24             	mov    %edi,(%esp)
  8007e6:	e8 36 03 00 00       	call   800b21 <printfmt>
  8007eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8007ee:	e9 b6 fe ff ff       	jmp    8006a9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8007f3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8007f7:	c7 44 24 08 32 31 80 	movl   $0x803132,0x8(%esp)
  8007fe:	00 
  8007ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800803:	89 3c 24             	mov    %edi,(%esp)
  800806:	e8 16 03 00 00       	call   800b21 <printfmt>
  80080b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80080e:	e9 96 fe ff ff       	jmp    8006a9 <vprintfmt+0x2c>
  800813:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800816:	89 c3                	mov    %eax,%ebx
  800818:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80081b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80081e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800821:	8b 45 14             	mov    0x14(%ebp),%eax
  800824:	8d 50 04             	lea    0x4(%eax),%edx
  800827:	89 55 14             	mov    %edx,0x14(%ebp)
  80082a:	8b 00                	mov    (%eax),%eax
  80082c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80082f:	85 c0                	test   %eax,%eax
  800831:	b8 5d 2d 80 00       	mov    $0x802d5d,%eax
  800836:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80083a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80083d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800841:	7e 06                	jle    800849 <vprintfmt+0x1cc>
  800843:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800847:	75 13                	jne    80085c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800849:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80084c:	0f be 02             	movsbl (%edx),%eax
  80084f:	85 c0                	test   %eax,%eax
  800851:	0f 85 9b 00 00 00    	jne    8008f2 <vprintfmt+0x275>
  800857:	e9 88 00 00 00       	jmp    8008e4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80085c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800860:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800863:	89 0c 24             	mov    %ecx,(%esp)
  800866:	e8 00 03 00 00       	call   800b6b <strnlen>
  80086b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80086e:	29 c2                	sub    %eax,%edx
  800870:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800873:	85 d2                	test   %edx,%edx
  800875:	7e d2                	jle    800849 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800877:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80087b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80087e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800881:	89 d3                	mov    %edx,%ebx
  800883:	89 74 24 04          	mov    %esi,0x4(%esp)
  800887:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80088a:	89 04 24             	mov    %eax,(%esp)
  80088d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80088f:	83 eb 01             	sub    $0x1,%ebx
  800892:	85 db                	test   %ebx,%ebx
  800894:	7f ed                	jg     800883 <vprintfmt+0x206>
  800896:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800899:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8008a0:	eb a7                	jmp    800849 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8008a2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8008a6:	74 1a                	je     8008c2 <vprintfmt+0x245>
  8008a8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8008ab:	83 fa 5e             	cmp    $0x5e,%edx
  8008ae:	76 12                	jbe    8008c2 <vprintfmt+0x245>
					putch('?', putdat);
  8008b0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8008b4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8008bb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8008be:	66 90                	xchg   %ax,%ax
  8008c0:	eb 0a                	jmp    8008cc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8008c2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8008c6:	89 04 24             	mov    %eax,(%esp)
  8008c9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8008cc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8008d0:	0f be 03             	movsbl (%ebx),%eax
  8008d3:	85 c0                	test   %eax,%eax
  8008d5:	74 05                	je     8008dc <vprintfmt+0x25f>
  8008d7:	83 c3 01             	add    $0x1,%ebx
  8008da:	eb 29                	jmp    800905 <vprintfmt+0x288>
  8008dc:	89 fe                	mov    %edi,%esi
  8008de:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8008e1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8008e4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8008e8:	7f 2e                	jg     800918 <vprintfmt+0x29b>
  8008ea:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8008ed:	e9 b7 fd ff ff       	jmp    8006a9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8008f2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8008f5:	83 c2 01             	add    $0x1,%edx
  8008f8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8008fb:	89 f7                	mov    %esi,%edi
  8008fd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800900:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800903:	89 d3                	mov    %edx,%ebx
  800905:	85 f6                	test   %esi,%esi
  800907:	78 99                	js     8008a2 <vprintfmt+0x225>
  800909:	83 ee 01             	sub    $0x1,%esi
  80090c:	79 94                	jns    8008a2 <vprintfmt+0x225>
  80090e:	89 fe                	mov    %edi,%esi
  800910:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800913:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800916:	eb cc                	jmp    8008e4 <vprintfmt+0x267>
  800918:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80091b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80091e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800922:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800929:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80092b:	83 eb 01             	sub    $0x1,%ebx
  80092e:	85 db                	test   %ebx,%ebx
  800930:	7f ec                	jg     80091e <vprintfmt+0x2a1>
  800932:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800935:	e9 6f fd ff ff       	jmp    8006a9 <vprintfmt+0x2c>
  80093a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80093d:	83 f9 01             	cmp    $0x1,%ecx
  800940:	7e 16                	jle    800958 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800942:	8b 45 14             	mov    0x14(%ebp),%eax
  800945:	8d 50 08             	lea    0x8(%eax),%edx
  800948:	89 55 14             	mov    %edx,0x14(%ebp)
  80094b:	8b 10                	mov    (%eax),%edx
  80094d:	8b 48 04             	mov    0x4(%eax),%ecx
  800950:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800953:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800956:	eb 32                	jmp    80098a <vprintfmt+0x30d>
	else if (lflag)
  800958:	85 c9                	test   %ecx,%ecx
  80095a:	74 18                	je     800974 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80095c:	8b 45 14             	mov    0x14(%ebp),%eax
  80095f:	8d 50 04             	lea    0x4(%eax),%edx
  800962:	89 55 14             	mov    %edx,0x14(%ebp)
  800965:	8b 00                	mov    (%eax),%eax
  800967:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80096a:	89 c1                	mov    %eax,%ecx
  80096c:	c1 f9 1f             	sar    $0x1f,%ecx
  80096f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800972:	eb 16                	jmp    80098a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800974:	8b 45 14             	mov    0x14(%ebp),%eax
  800977:	8d 50 04             	lea    0x4(%eax),%edx
  80097a:	89 55 14             	mov    %edx,0x14(%ebp)
  80097d:	8b 00                	mov    (%eax),%eax
  80097f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800982:	89 c2                	mov    %eax,%edx
  800984:	c1 fa 1f             	sar    $0x1f,%edx
  800987:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80098a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80098d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800990:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800995:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800999:	0f 89 9b 00 00 00    	jns    800a3a <vprintfmt+0x3bd>
				putch('-', putdat);
  80099f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009a3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8009aa:	ff d7                	call   *%edi
				num = -(long long) num;
  8009ac:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8009af:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8009b2:	f7 d9                	neg    %ecx
  8009b4:	83 d3 00             	adc    $0x0,%ebx
  8009b7:	f7 db                	neg    %ebx
  8009b9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8009be:	eb 7a                	jmp    800a3a <vprintfmt+0x3bd>
  8009c0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8009c3:	89 ca                	mov    %ecx,%edx
  8009c5:	8d 45 14             	lea    0x14(%ebp),%eax
  8009c8:	e8 59 fc ff ff       	call   800626 <getuint>
  8009cd:	89 c1                	mov    %eax,%ecx
  8009cf:	89 d3                	mov    %edx,%ebx
  8009d1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8009d6:	eb 62                	jmp    800a3a <vprintfmt+0x3bd>
  8009d8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8009db:	89 ca                	mov    %ecx,%edx
  8009dd:	8d 45 14             	lea    0x14(%ebp),%eax
  8009e0:	e8 41 fc ff ff       	call   800626 <getuint>
  8009e5:	89 c1                	mov    %eax,%ecx
  8009e7:	89 d3                	mov    %edx,%ebx
  8009e9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8009ee:	eb 4a                	jmp    800a3a <vprintfmt+0x3bd>
  8009f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8009f3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8009f7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8009fe:	ff d7                	call   *%edi
			putch('x', putdat);
  800a00:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a04:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  800a0b:	ff d7                	call   *%edi
			num = (unsigned long long)
  800a0d:	8b 45 14             	mov    0x14(%ebp),%eax
  800a10:	8d 50 04             	lea    0x4(%eax),%edx
  800a13:	89 55 14             	mov    %edx,0x14(%ebp)
  800a16:	8b 08                	mov    (%eax),%ecx
  800a18:	bb 00 00 00 00       	mov    $0x0,%ebx
  800a1d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800a22:	eb 16                	jmp    800a3a <vprintfmt+0x3bd>
  800a24:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800a27:	89 ca                	mov    %ecx,%edx
  800a29:	8d 45 14             	lea    0x14(%ebp),%eax
  800a2c:	e8 f5 fb ff ff       	call   800626 <getuint>
  800a31:	89 c1                	mov    %eax,%ecx
  800a33:	89 d3                	mov    %edx,%ebx
  800a35:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  800a3a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  800a3e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800a42:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800a45:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800a49:	89 44 24 08          	mov    %eax,0x8(%esp)
  800a4d:	89 0c 24             	mov    %ecx,(%esp)
  800a50:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800a54:	89 f2                	mov    %esi,%edx
  800a56:	89 f8                	mov    %edi,%eax
  800a58:	e8 d3 fa ff ff       	call   800530 <printnum>
  800a5d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800a60:	e9 44 fc ff ff       	jmp    8006a9 <vprintfmt+0x2c>
  800a65:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800a68:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  800a6b:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a6f:	89 14 24             	mov    %edx,(%esp)
  800a72:	ff d7                	call   *%edi
  800a74:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800a77:	e9 2d fc ff ff       	jmp    8006a9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  800a7c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a80:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800a87:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800a89:	8d 43 ff             	lea    -0x1(%ebx),%eax
  800a8c:	80 38 25             	cmpb   $0x25,(%eax)
  800a8f:	0f 84 14 fc ff ff    	je     8006a9 <vprintfmt+0x2c>
  800a95:	89 c3                	mov    %eax,%ebx
  800a97:	eb f0                	jmp    800a89 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800a99:	83 c4 5c             	add    $0x5c,%esp
  800a9c:	5b                   	pop    %ebx
  800a9d:	5e                   	pop    %esi
  800a9e:	5f                   	pop    %edi
  800a9f:	5d                   	pop    %ebp
  800aa0:	c3                   	ret    

00800aa1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800aa1:	55                   	push   %ebp
  800aa2:	89 e5                	mov    %esp,%ebp
  800aa4:	83 ec 28             	sub    $0x28,%esp
  800aa7:	8b 45 08             	mov    0x8(%ebp),%eax
  800aaa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  800aad:	85 c0                	test   %eax,%eax
  800aaf:	74 04                	je     800ab5 <vsnprintf+0x14>
  800ab1:	85 d2                	test   %edx,%edx
  800ab3:	7f 07                	jg     800abc <vsnprintf+0x1b>
  800ab5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  800aba:	eb 3b                	jmp    800af7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  800abc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  800abf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  800ac3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  800ac6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  800acd:	8b 45 14             	mov    0x14(%ebp),%eax
  800ad0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800ad4:	8b 45 10             	mov    0x10(%ebp),%eax
  800ad7:	89 44 24 08          	mov    %eax,0x8(%esp)
  800adb:	8d 45 ec             	lea    -0x14(%ebp),%eax
  800ade:	89 44 24 04          	mov    %eax,0x4(%esp)
  800ae2:	c7 04 24 60 06 80 00 	movl   $0x800660,(%esp)
  800ae9:	e8 8f fb ff ff       	call   80067d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  800aee:	8b 45 ec             	mov    -0x14(%ebp),%eax
  800af1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  800af4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  800af7:	c9                   	leave  
  800af8:	c3                   	ret    

00800af9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  800af9:	55                   	push   %ebp
  800afa:	89 e5                	mov    %esp,%ebp
  800afc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  800aff:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800b02:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b06:	8b 45 10             	mov    0x10(%ebp),%eax
  800b09:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b0d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b10:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b14:	8b 45 08             	mov    0x8(%ebp),%eax
  800b17:	89 04 24             	mov    %eax,(%esp)
  800b1a:	e8 82 ff ff ff       	call   800aa1 <vsnprintf>
	va_end(ap);

	return rc;
}
  800b1f:	c9                   	leave  
  800b20:	c3                   	ret    

00800b21 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800b21:	55                   	push   %ebp
  800b22:	89 e5                	mov    %esp,%ebp
  800b24:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800b27:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  800b2a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800b2e:	8b 45 10             	mov    0x10(%ebp),%eax
  800b31:	89 44 24 08          	mov    %eax,0x8(%esp)
  800b35:	8b 45 0c             	mov    0xc(%ebp),%eax
  800b38:	89 44 24 04          	mov    %eax,0x4(%esp)
  800b3c:	8b 45 08             	mov    0x8(%ebp),%eax
  800b3f:	89 04 24             	mov    %eax,(%esp)
  800b42:	e8 36 fb ff ff       	call   80067d <vprintfmt>
	va_end(ap);
}
  800b47:	c9                   	leave  
  800b48:	c3                   	ret    
  800b49:	00 00                	add    %al,(%eax)
  800b4b:	00 00                	add    %al,(%eax)
  800b4d:	00 00                	add    %al,(%eax)
	...

00800b50 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800b50:	55                   	push   %ebp
  800b51:	89 e5                	mov    %esp,%ebp
  800b53:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800b56:	b8 00 00 00 00       	mov    $0x0,%eax
  800b5b:	80 3a 00             	cmpb   $0x0,(%edx)
  800b5e:	74 09                	je     800b69 <strlen+0x19>
		n++;
  800b60:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800b63:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800b67:	75 f7                	jne    800b60 <strlen+0x10>
		n++;
	return n;
}
  800b69:	5d                   	pop    %ebp
  800b6a:	c3                   	ret    

00800b6b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  800b6b:	55                   	push   %ebp
  800b6c:	89 e5                	mov    %esp,%ebp
  800b6e:	53                   	push   %ebx
  800b6f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800b72:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800b75:	85 c9                	test   %ecx,%ecx
  800b77:	74 19                	je     800b92 <strnlen+0x27>
  800b79:	80 3b 00             	cmpb   $0x0,(%ebx)
  800b7c:	74 14                	je     800b92 <strnlen+0x27>
  800b7e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800b83:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800b86:	39 c8                	cmp    %ecx,%eax
  800b88:	74 0d                	je     800b97 <strnlen+0x2c>
  800b8a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  800b8e:	75 f3                	jne    800b83 <strnlen+0x18>
  800b90:	eb 05                	jmp    800b97 <strnlen+0x2c>
  800b92:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800b97:	5b                   	pop    %ebx
  800b98:	5d                   	pop    %ebp
  800b99:	c3                   	ret    

00800b9a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  800b9a:	55                   	push   %ebp
  800b9b:	89 e5                	mov    %esp,%ebp
  800b9d:	53                   	push   %ebx
  800b9e:	8b 45 08             	mov    0x8(%ebp),%eax
  800ba1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800ba4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800ba9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  800bad:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800bb0:	83 c2 01             	add    $0x1,%edx
  800bb3:	84 c9                	test   %cl,%cl
  800bb5:	75 f2                	jne    800ba9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800bb7:	5b                   	pop    %ebx
  800bb8:	5d                   	pop    %ebp
  800bb9:	c3                   	ret    

00800bba <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  800bba:	55                   	push   %ebp
  800bbb:	89 e5                	mov    %esp,%ebp
  800bbd:	56                   	push   %esi
  800bbe:	53                   	push   %ebx
  800bbf:	8b 45 08             	mov    0x8(%ebp),%eax
  800bc2:	8b 55 0c             	mov    0xc(%ebp),%edx
  800bc5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800bc8:	85 f6                	test   %esi,%esi
  800bca:	74 18                	je     800be4 <strncpy+0x2a>
  800bcc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  800bd1:	0f b6 1a             	movzbl (%edx),%ebx
  800bd4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  800bd7:	80 3a 01             	cmpb   $0x1,(%edx)
  800bda:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  800bdd:	83 c1 01             	add    $0x1,%ecx
  800be0:	39 ce                	cmp    %ecx,%esi
  800be2:	77 ed                	ja     800bd1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  800be4:	5b                   	pop    %ebx
  800be5:	5e                   	pop    %esi
  800be6:	5d                   	pop    %ebp
  800be7:	c3                   	ret    

00800be8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  800be8:	55                   	push   %ebp
  800be9:	89 e5                	mov    %esp,%ebp
  800beb:	56                   	push   %esi
  800bec:	53                   	push   %ebx
  800bed:	8b 75 08             	mov    0x8(%ebp),%esi
  800bf0:	8b 55 0c             	mov    0xc(%ebp),%edx
  800bf3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  800bf6:	89 f0                	mov    %esi,%eax
  800bf8:	85 c9                	test   %ecx,%ecx
  800bfa:	74 27                	je     800c23 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  800bfc:	83 e9 01             	sub    $0x1,%ecx
  800bff:	74 1d                	je     800c1e <strlcpy+0x36>
  800c01:	0f b6 1a             	movzbl (%edx),%ebx
  800c04:	84 db                	test   %bl,%bl
  800c06:	74 16                	je     800c1e <strlcpy+0x36>
			*dst++ = *src++;
  800c08:	88 18                	mov    %bl,(%eax)
  800c0a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c0d:	83 e9 01             	sub    $0x1,%ecx
  800c10:	74 0e                	je     800c20 <strlcpy+0x38>
			*dst++ = *src++;
  800c12:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800c15:	0f b6 1a             	movzbl (%edx),%ebx
  800c18:	84 db                	test   %bl,%bl
  800c1a:	75 ec                	jne    800c08 <strlcpy+0x20>
  800c1c:	eb 02                	jmp    800c20 <strlcpy+0x38>
  800c1e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800c20:	c6 00 00             	movb   $0x0,(%eax)
  800c23:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800c25:	5b                   	pop    %ebx
  800c26:	5e                   	pop    %esi
  800c27:	5d                   	pop    %ebp
  800c28:	c3                   	ret    

00800c29 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800c29:	55                   	push   %ebp
  800c2a:	89 e5                	mov    %esp,%ebp
  800c2c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800c2f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800c32:	0f b6 01             	movzbl (%ecx),%eax
  800c35:	84 c0                	test   %al,%al
  800c37:	74 15                	je     800c4e <strcmp+0x25>
  800c39:	3a 02                	cmp    (%edx),%al
  800c3b:	75 11                	jne    800c4e <strcmp+0x25>
		p++, q++;
  800c3d:	83 c1 01             	add    $0x1,%ecx
  800c40:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800c43:	0f b6 01             	movzbl (%ecx),%eax
  800c46:	84 c0                	test   %al,%al
  800c48:	74 04                	je     800c4e <strcmp+0x25>
  800c4a:	3a 02                	cmp    (%edx),%al
  800c4c:	74 ef                	je     800c3d <strcmp+0x14>
  800c4e:	0f b6 c0             	movzbl %al,%eax
  800c51:	0f b6 12             	movzbl (%edx),%edx
  800c54:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800c56:	5d                   	pop    %ebp
  800c57:	c3                   	ret    

00800c58 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800c58:	55                   	push   %ebp
  800c59:	89 e5                	mov    %esp,%ebp
  800c5b:	53                   	push   %ebx
  800c5c:	8b 55 08             	mov    0x8(%ebp),%edx
  800c5f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800c62:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800c65:	85 c0                	test   %eax,%eax
  800c67:	74 23                	je     800c8c <strncmp+0x34>
  800c69:	0f b6 1a             	movzbl (%edx),%ebx
  800c6c:	84 db                	test   %bl,%bl
  800c6e:	74 24                	je     800c94 <strncmp+0x3c>
  800c70:	3a 19                	cmp    (%ecx),%bl
  800c72:	75 20                	jne    800c94 <strncmp+0x3c>
  800c74:	83 e8 01             	sub    $0x1,%eax
  800c77:	74 13                	je     800c8c <strncmp+0x34>
		n--, p++, q++;
  800c79:	83 c2 01             	add    $0x1,%edx
  800c7c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800c7f:	0f b6 1a             	movzbl (%edx),%ebx
  800c82:	84 db                	test   %bl,%bl
  800c84:	74 0e                	je     800c94 <strncmp+0x3c>
  800c86:	3a 19                	cmp    (%ecx),%bl
  800c88:	74 ea                	je     800c74 <strncmp+0x1c>
  800c8a:	eb 08                	jmp    800c94 <strncmp+0x3c>
  800c8c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800c91:	5b                   	pop    %ebx
  800c92:	5d                   	pop    %ebp
  800c93:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800c94:	0f b6 02             	movzbl (%edx),%eax
  800c97:	0f b6 11             	movzbl (%ecx),%edx
  800c9a:	29 d0                	sub    %edx,%eax
  800c9c:	eb f3                	jmp    800c91 <strncmp+0x39>

00800c9e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800c9e:	55                   	push   %ebp
  800c9f:	89 e5                	mov    %esp,%ebp
  800ca1:	8b 45 08             	mov    0x8(%ebp),%eax
  800ca4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ca8:	0f b6 10             	movzbl (%eax),%edx
  800cab:	84 d2                	test   %dl,%dl
  800cad:	74 15                	je     800cc4 <strchr+0x26>
		if (*s == c)
  800caf:	38 ca                	cmp    %cl,%dl
  800cb1:	75 07                	jne    800cba <strchr+0x1c>
  800cb3:	eb 14                	jmp    800cc9 <strchr+0x2b>
  800cb5:	38 ca                	cmp    %cl,%dl
  800cb7:	90                   	nop
  800cb8:	74 0f                	je     800cc9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800cba:	83 c0 01             	add    $0x1,%eax
  800cbd:	0f b6 10             	movzbl (%eax),%edx
  800cc0:	84 d2                	test   %dl,%dl
  800cc2:	75 f1                	jne    800cb5 <strchr+0x17>
  800cc4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800cc9:	5d                   	pop    %ebp
  800cca:	c3                   	ret    

00800ccb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800ccb:	55                   	push   %ebp
  800ccc:	89 e5                	mov    %esp,%ebp
  800cce:	8b 45 08             	mov    0x8(%ebp),%eax
  800cd1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800cd5:	0f b6 10             	movzbl (%eax),%edx
  800cd8:	84 d2                	test   %dl,%dl
  800cda:	74 18                	je     800cf4 <strfind+0x29>
		if (*s == c)
  800cdc:	38 ca                	cmp    %cl,%dl
  800cde:	75 0a                	jne    800cea <strfind+0x1f>
  800ce0:	eb 12                	jmp    800cf4 <strfind+0x29>
  800ce2:	38 ca                	cmp    %cl,%dl
  800ce4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800ce8:	74 0a                	je     800cf4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800cea:	83 c0 01             	add    $0x1,%eax
  800ced:	0f b6 10             	movzbl (%eax),%edx
  800cf0:	84 d2                	test   %dl,%dl
  800cf2:	75 ee                	jne    800ce2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800cf4:	5d                   	pop    %ebp
  800cf5:	c3                   	ret    

00800cf6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800cf6:	55                   	push   %ebp
  800cf7:	89 e5                	mov    %esp,%ebp
  800cf9:	83 ec 0c             	sub    $0xc,%esp
  800cfc:	89 1c 24             	mov    %ebx,(%esp)
  800cff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d03:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800d07:	8b 7d 08             	mov    0x8(%ebp),%edi
  800d0a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800d0d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800d10:	85 c9                	test   %ecx,%ecx
  800d12:	74 30                	je     800d44 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d14:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d1a:	75 25                	jne    800d41 <memset+0x4b>
  800d1c:	f6 c1 03             	test   $0x3,%cl
  800d1f:	75 20                	jne    800d41 <memset+0x4b>
		c &= 0xFF;
  800d21:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800d24:	89 d3                	mov    %edx,%ebx
  800d26:	c1 e3 08             	shl    $0x8,%ebx
  800d29:	89 d6                	mov    %edx,%esi
  800d2b:	c1 e6 18             	shl    $0x18,%esi
  800d2e:	89 d0                	mov    %edx,%eax
  800d30:	c1 e0 10             	shl    $0x10,%eax
  800d33:	09 f0                	or     %esi,%eax
  800d35:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800d37:	09 d8                	or     %ebx,%eax
  800d39:	c1 e9 02             	shr    $0x2,%ecx
  800d3c:	fc                   	cld    
  800d3d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800d3f:	eb 03                	jmp    800d44 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800d41:	fc                   	cld    
  800d42:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800d44:	89 f8                	mov    %edi,%eax
  800d46:	8b 1c 24             	mov    (%esp),%ebx
  800d49:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d4d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d51:	89 ec                	mov    %ebp,%esp
  800d53:	5d                   	pop    %ebp
  800d54:	c3                   	ret    

00800d55 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800d55:	55                   	push   %ebp
  800d56:	89 e5                	mov    %esp,%ebp
  800d58:	83 ec 08             	sub    $0x8,%esp
  800d5b:	89 34 24             	mov    %esi,(%esp)
  800d5e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800d62:	8b 45 08             	mov    0x8(%ebp),%eax
  800d65:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800d68:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800d6b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800d6d:	39 c6                	cmp    %eax,%esi
  800d6f:	73 35                	jae    800da6 <memmove+0x51>
  800d71:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800d74:	39 d0                	cmp    %edx,%eax
  800d76:	73 2e                	jae    800da6 <memmove+0x51>
		s += n;
		d += n;
  800d78:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d7a:	f6 c2 03             	test   $0x3,%dl
  800d7d:	75 1b                	jne    800d9a <memmove+0x45>
  800d7f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800d85:	75 13                	jne    800d9a <memmove+0x45>
  800d87:	f6 c1 03             	test   $0x3,%cl
  800d8a:	75 0e                	jne    800d9a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800d8c:	83 ef 04             	sub    $0x4,%edi
  800d8f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800d92:	c1 e9 02             	shr    $0x2,%ecx
  800d95:	fd                   	std    
  800d96:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800d98:	eb 09                	jmp    800da3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800d9a:	83 ef 01             	sub    $0x1,%edi
  800d9d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800da0:	fd                   	std    
  800da1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800da3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800da4:	eb 20                	jmp    800dc6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800da6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800dac:	75 15                	jne    800dc3 <memmove+0x6e>
  800dae:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800db4:	75 0d                	jne    800dc3 <memmove+0x6e>
  800db6:	f6 c1 03             	test   $0x3,%cl
  800db9:	75 08                	jne    800dc3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800dbb:	c1 e9 02             	shr    $0x2,%ecx
  800dbe:	fc                   	cld    
  800dbf:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800dc1:	eb 03                	jmp    800dc6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800dc3:	fc                   	cld    
  800dc4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800dc6:	8b 34 24             	mov    (%esp),%esi
  800dc9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800dcd:	89 ec                	mov    %ebp,%esp
  800dcf:	5d                   	pop    %ebp
  800dd0:	c3                   	ret    

00800dd1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800dd1:	55                   	push   %ebp
  800dd2:	89 e5                	mov    %esp,%ebp
  800dd4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800dd7:	8b 45 10             	mov    0x10(%ebp),%eax
  800dda:	89 44 24 08          	mov    %eax,0x8(%esp)
  800dde:	8b 45 0c             	mov    0xc(%ebp),%eax
  800de1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800de5:	8b 45 08             	mov    0x8(%ebp),%eax
  800de8:	89 04 24             	mov    %eax,(%esp)
  800deb:	e8 65 ff ff ff       	call   800d55 <memmove>
}
  800df0:	c9                   	leave  
  800df1:	c3                   	ret    

00800df2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800df2:	55                   	push   %ebp
  800df3:	89 e5                	mov    %esp,%ebp
  800df5:	57                   	push   %edi
  800df6:	56                   	push   %esi
  800df7:	53                   	push   %ebx
  800df8:	8b 75 08             	mov    0x8(%ebp),%esi
  800dfb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800dfe:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e01:	85 c9                	test   %ecx,%ecx
  800e03:	74 36                	je     800e3b <memcmp+0x49>
		if (*s1 != *s2)
  800e05:	0f b6 06             	movzbl (%esi),%eax
  800e08:	0f b6 1f             	movzbl (%edi),%ebx
  800e0b:	38 d8                	cmp    %bl,%al
  800e0d:	74 20                	je     800e2f <memcmp+0x3d>
  800e0f:	eb 14                	jmp    800e25 <memcmp+0x33>
  800e11:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800e16:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800e1b:	83 c2 01             	add    $0x1,%edx
  800e1e:	83 e9 01             	sub    $0x1,%ecx
  800e21:	38 d8                	cmp    %bl,%al
  800e23:	74 12                	je     800e37 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800e25:	0f b6 c0             	movzbl %al,%eax
  800e28:	0f b6 db             	movzbl %bl,%ebx
  800e2b:	29 d8                	sub    %ebx,%eax
  800e2d:	eb 11                	jmp    800e40 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800e2f:	83 e9 01             	sub    $0x1,%ecx
  800e32:	ba 00 00 00 00       	mov    $0x0,%edx
  800e37:	85 c9                	test   %ecx,%ecx
  800e39:	75 d6                	jne    800e11 <memcmp+0x1f>
  800e3b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800e40:	5b                   	pop    %ebx
  800e41:	5e                   	pop    %esi
  800e42:	5f                   	pop    %edi
  800e43:	5d                   	pop    %ebp
  800e44:	c3                   	ret    

00800e45 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800e45:	55                   	push   %ebp
  800e46:	89 e5                	mov    %esp,%ebp
  800e48:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800e4b:	89 c2                	mov    %eax,%edx
  800e4d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800e50:	39 d0                	cmp    %edx,%eax
  800e52:	73 15                	jae    800e69 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800e54:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800e58:	38 08                	cmp    %cl,(%eax)
  800e5a:	75 06                	jne    800e62 <memfind+0x1d>
  800e5c:	eb 0b                	jmp    800e69 <memfind+0x24>
  800e5e:	38 08                	cmp    %cl,(%eax)
  800e60:	74 07                	je     800e69 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800e62:	83 c0 01             	add    $0x1,%eax
  800e65:	39 c2                	cmp    %eax,%edx
  800e67:	77 f5                	ja     800e5e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800e69:	5d                   	pop    %ebp
  800e6a:	c3                   	ret    

00800e6b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800e6b:	55                   	push   %ebp
  800e6c:	89 e5                	mov    %esp,%ebp
  800e6e:	57                   	push   %edi
  800e6f:	56                   	push   %esi
  800e70:	53                   	push   %ebx
  800e71:	83 ec 04             	sub    $0x4,%esp
  800e74:	8b 55 08             	mov    0x8(%ebp),%edx
  800e77:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e7a:	0f b6 02             	movzbl (%edx),%eax
  800e7d:	3c 20                	cmp    $0x20,%al
  800e7f:	74 04                	je     800e85 <strtol+0x1a>
  800e81:	3c 09                	cmp    $0x9,%al
  800e83:	75 0e                	jne    800e93 <strtol+0x28>
		s++;
  800e85:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800e88:	0f b6 02             	movzbl (%edx),%eax
  800e8b:	3c 20                	cmp    $0x20,%al
  800e8d:	74 f6                	je     800e85 <strtol+0x1a>
  800e8f:	3c 09                	cmp    $0x9,%al
  800e91:	74 f2                	je     800e85 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800e93:	3c 2b                	cmp    $0x2b,%al
  800e95:	75 0c                	jne    800ea3 <strtol+0x38>
		s++;
  800e97:	83 c2 01             	add    $0x1,%edx
  800e9a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800ea1:	eb 15                	jmp    800eb8 <strtol+0x4d>
	else if (*s == '-')
  800ea3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800eaa:	3c 2d                	cmp    $0x2d,%al
  800eac:	75 0a                	jne    800eb8 <strtol+0x4d>
		s++, neg = 1;
  800eae:	83 c2 01             	add    $0x1,%edx
  800eb1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800eb8:	85 db                	test   %ebx,%ebx
  800eba:	0f 94 c0             	sete   %al
  800ebd:	74 05                	je     800ec4 <strtol+0x59>
  800ebf:	83 fb 10             	cmp    $0x10,%ebx
  800ec2:	75 18                	jne    800edc <strtol+0x71>
  800ec4:	80 3a 30             	cmpb   $0x30,(%edx)
  800ec7:	75 13                	jne    800edc <strtol+0x71>
  800ec9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800ecd:	8d 76 00             	lea    0x0(%esi),%esi
  800ed0:	75 0a                	jne    800edc <strtol+0x71>
		s += 2, base = 16;
  800ed2:	83 c2 02             	add    $0x2,%edx
  800ed5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800eda:	eb 15                	jmp    800ef1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800edc:	84 c0                	test   %al,%al
  800ede:	66 90                	xchg   %ax,%ax
  800ee0:	74 0f                	je     800ef1 <strtol+0x86>
  800ee2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800ee7:	80 3a 30             	cmpb   $0x30,(%edx)
  800eea:	75 05                	jne    800ef1 <strtol+0x86>
		s++, base = 8;
  800eec:	83 c2 01             	add    $0x1,%edx
  800eef:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800ef1:	b8 00 00 00 00       	mov    $0x0,%eax
  800ef6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800ef8:	0f b6 0a             	movzbl (%edx),%ecx
  800efb:	89 cf                	mov    %ecx,%edi
  800efd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800f00:	80 fb 09             	cmp    $0x9,%bl
  800f03:	77 08                	ja     800f0d <strtol+0xa2>
			dig = *s - '0';
  800f05:	0f be c9             	movsbl %cl,%ecx
  800f08:	83 e9 30             	sub    $0x30,%ecx
  800f0b:	eb 1e                	jmp    800f2b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800f0d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800f10:	80 fb 19             	cmp    $0x19,%bl
  800f13:	77 08                	ja     800f1d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800f15:	0f be c9             	movsbl %cl,%ecx
  800f18:	83 e9 57             	sub    $0x57,%ecx
  800f1b:	eb 0e                	jmp    800f2b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800f1d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800f20:	80 fb 19             	cmp    $0x19,%bl
  800f23:	77 15                	ja     800f3a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800f25:	0f be c9             	movsbl %cl,%ecx
  800f28:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800f2b:	39 f1                	cmp    %esi,%ecx
  800f2d:	7d 0b                	jge    800f3a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800f2f:	83 c2 01             	add    $0x1,%edx
  800f32:	0f af c6             	imul   %esi,%eax
  800f35:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800f38:	eb be                	jmp    800ef8 <strtol+0x8d>
  800f3a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800f3c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800f40:	74 05                	je     800f47 <strtol+0xdc>
		*endptr = (char *) s;
  800f42:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800f45:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800f47:	89 ca                	mov    %ecx,%edx
  800f49:	f7 da                	neg    %edx
  800f4b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800f4f:	0f 45 c2             	cmovne %edx,%eax
}
  800f52:	83 c4 04             	add    $0x4,%esp
  800f55:	5b                   	pop    %ebx
  800f56:	5e                   	pop    %esi
  800f57:	5f                   	pop    %edi
  800f58:	5d                   	pop    %ebp
  800f59:	c3                   	ret    
	...

00800f5c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800f5c:	55                   	push   %ebp
  800f5d:	89 e5                	mov    %esp,%ebp
  800f5f:	83 ec 0c             	sub    $0xc,%esp
  800f62:	89 1c 24             	mov    %ebx,(%esp)
  800f65:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f69:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f6d:	ba 00 00 00 00       	mov    $0x0,%edx
  800f72:	b8 01 00 00 00       	mov    $0x1,%eax
  800f77:	89 d1                	mov    %edx,%ecx
  800f79:	89 d3                	mov    %edx,%ebx
  800f7b:	89 d7                	mov    %edx,%edi
  800f7d:	89 d6                	mov    %edx,%esi
  800f7f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800f81:	8b 1c 24             	mov    (%esp),%ebx
  800f84:	8b 74 24 04          	mov    0x4(%esp),%esi
  800f88:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800f8c:	89 ec                	mov    %ebp,%esp
  800f8e:	5d                   	pop    %ebp
  800f8f:	c3                   	ret    

00800f90 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800f90:	55                   	push   %ebp
  800f91:	89 e5                	mov    %esp,%ebp
  800f93:	83 ec 0c             	sub    $0xc,%esp
  800f96:	89 1c 24             	mov    %ebx,(%esp)
  800f99:	89 74 24 04          	mov    %esi,0x4(%esp)
  800f9d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fa1:	b8 00 00 00 00       	mov    $0x0,%eax
  800fa6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fa9:	8b 55 08             	mov    0x8(%ebp),%edx
  800fac:	89 c3                	mov    %eax,%ebx
  800fae:	89 c7                	mov    %eax,%edi
  800fb0:	89 c6                	mov    %eax,%esi
  800fb2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800fb4:	8b 1c 24             	mov    (%esp),%ebx
  800fb7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800fbb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800fbf:	89 ec                	mov    %ebp,%esp
  800fc1:	5d                   	pop    %ebp
  800fc2:	c3                   	ret    

00800fc3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800fc3:	55                   	push   %ebp
  800fc4:	89 e5                	mov    %esp,%ebp
  800fc6:	83 ec 0c             	sub    $0xc,%esp
  800fc9:	89 1c 24             	mov    %ebx,(%esp)
  800fcc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800fd0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fd4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fd9:	b8 10 00 00 00       	mov    $0x10,%eax
  800fde:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fe1:	8b 55 08             	mov    0x8(%ebp),%edx
  800fe4:	89 df                	mov    %ebx,%edi
  800fe6:	89 de                	mov    %ebx,%esi
  800fe8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800fea:	8b 1c 24             	mov    (%esp),%ebx
  800fed:	8b 74 24 04          	mov    0x4(%esp),%esi
  800ff1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800ff5:	89 ec                	mov    %ebp,%esp
  800ff7:	5d                   	pop    %ebp
  800ff8:	c3                   	ret    

00800ff9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800ff9:	55                   	push   %ebp
  800ffa:	89 e5                	mov    %esp,%ebp
  800ffc:	83 ec 0c             	sub    $0xc,%esp
  800fff:	89 1c 24             	mov    %ebx,(%esp)
  801002:	89 74 24 04          	mov    %esi,0x4(%esp)
  801006:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80100a:	bb 00 00 00 00       	mov    $0x0,%ebx
  80100f:	b8 0f 00 00 00       	mov    $0xf,%eax
  801014:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801017:	8b 55 08             	mov    0x8(%ebp),%edx
  80101a:	89 df                	mov    %ebx,%edi
  80101c:	89 de                	mov    %ebx,%esi
  80101e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  801020:	8b 1c 24             	mov    (%esp),%ebx
  801023:	8b 74 24 04          	mov    0x4(%esp),%esi
  801027:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80102b:	89 ec                	mov    %ebp,%esp
  80102d:	5d                   	pop    %ebp
  80102e:	c3                   	ret    

0080102f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  80102f:	55                   	push   %ebp
  801030:	89 e5                	mov    %esp,%ebp
  801032:	83 ec 0c             	sub    $0xc,%esp
  801035:	89 1c 24             	mov    %ebx,(%esp)
  801038:	89 74 24 04          	mov    %esi,0x4(%esp)
  80103c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801040:	ba 00 00 00 00       	mov    $0x0,%edx
  801045:	b8 0e 00 00 00       	mov    $0xe,%eax
  80104a:	89 d1                	mov    %edx,%ecx
  80104c:	89 d3                	mov    %edx,%ebx
  80104e:	89 d7                	mov    %edx,%edi
  801050:	89 d6                	mov    %edx,%esi
  801052:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  801054:	8b 1c 24             	mov    (%esp),%ebx
  801057:	8b 74 24 04          	mov    0x4(%esp),%esi
  80105b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  80105f:	89 ec                	mov    %ebp,%esp
  801061:	5d                   	pop    %ebp
  801062:	c3                   	ret    

00801063 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  801063:	55                   	push   %ebp
  801064:	89 e5                	mov    %esp,%ebp
  801066:	83 ec 38             	sub    $0x38,%esp
  801069:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  80106c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80106f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801072:	b9 00 00 00 00       	mov    $0x0,%ecx
  801077:	b8 0d 00 00 00       	mov    $0xd,%eax
  80107c:	8b 55 08             	mov    0x8(%ebp),%edx
  80107f:	89 cb                	mov    %ecx,%ebx
  801081:	89 cf                	mov    %ecx,%edi
  801083:	89 ce                	mov    %ecx,%esi
  801085:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801087:	85 c0                	test   %eax,%eax
  801089:	7e 28                	jle    8010b3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  80108b:	89 44 24 10          	mov    %eax,0x10(%esp)
  80108f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  801096:	00 
  801097:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  80109e:	00 
  80109f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010a6:	00 
  8010a7:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  8010ae:	e8 4d f3 ff ff       	call   800400 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  8010b3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010b6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010b9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010bc:	89 ec                	mov    %ebp,%esp
  8010be:	5d                   	pop    %ebp
  8010bf:	c3                   	ret    

008010c0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  8010c0:	55                   	push   %ebp
  8010c1:	89 e5                	mov    %esp,%ebp
  8010c3:	83 ec 38             	sub    $0x38,%esp
  8010c6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010c9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010cc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010cf:	be 00 00 00 00       	mov    $0x0,%esi
  8010d4:	b8 0c 00 00 00       	mov    $0xc,%eax
  8010d9:	8b 7d 14             	mov    0x14(%ebp),%edi
  8010dc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010df:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010e2:	8b 55 08             	mov    0x8(%ebp),%edx
  8010e5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010e7:	85 c0                	test   %eax,%eax
  8010e9:	7e 28                	jle    801113 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010eb:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010ef:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  8010f6:	00 
  8010f7:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  8010fe:	00 
  8010ff:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801106:	00 
  801107:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  80110e:	e8 ed f2 ff ff       	call   800400 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  801113:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801116:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801119:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80111c:	89 ec                	mov    %ebp,%esp
  80111e:	5d                   	pop    %ebp
  80111f:	c3                   	ret    

00801120 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  801120:	55                   	push   %ebp
  801121:	89 e5                	mov    %esp,%ebp
  801123:	83 ec 38             	sub    $0x38,%esp
  801126:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801129:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80112c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80112f:	bb 00 00 00 00       	mov    $0x0,%ebx
  801134:	b8 0a 00 00 00       	mov    $0xa,%eax
  801139:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80113c:	8b 55 08             	mov    0x8(%ebp),%edx
  80113f:	89 df                	mov    %ebx,%edi
  801141:	89 de                	mov    %ebx,%esi
  801143:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801145:	85 c0                	test   %eax,%eax
  801147:	7e 28                	jle    801171 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801149:	89 44 24 10          	mov    %eax,0x10(%esp)
  80114d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  801154:	00 
  801155:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  80115c:	00 
  80115d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801164:	00 
  801165:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  80116c:	e8 8f f2 ff ff       	call   800400 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  801171:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801174:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801177:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80117a:	89 ec                	mov    %ebp,%esp
  80117c:	5d                   	pop    %ebp
  80117d:	c3                   	ret    

0080117e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  80117e:	55                   	push   %ebp
  80117f:	89 e5                	mov    %esp,%ebp
  801181:	83 ec 38             	sub    $0x38,%esp
  801184:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801187:	89 75 f8             	mov    %esi,-0x8(%ebp)
  80118a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80118d:	bb 00 00 00 00       	mov    $0x0,%ebx
  801192:	b8 09 00 00 00       	mov    $0x9,%eax
  801197:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80119a:	8b 55 08             	mov    0x8(%ebp),%edx
  80119d:	89 df                	mov    %ebx,%edi
  80119f:	89 de                	mov    %ebx,%esi
  8011a1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011a3:	85 c0                	test   %eax,%eax
  8011a5:	7e 28                	jle    8011cf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011a7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011ab:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  8011b2:	00 
  8011b3:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  8011ba:	00 
  8011bb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011c2:	00 
  8011c3:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  8011ca:	e8 31 f2 ff ff       	call   800400 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  8011cf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011d2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011d5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011d8:	89 ec                	mov    %ebp,%esp
  8011da:	5d                   	pop    %ebp
  8011db:	c3                   	ret    

008011dc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  8011dc:	55                   	push   %ebp
  8011dd:	89 e5                	mov    %esp,%ebp
  8011df:	83 ec 38             	sub    $0x38,%esp
  8011e2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011e5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011e8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011eb:	bb 00 00 00 00       	mov    $0x0,%ebx
  8011f0:	b8 08 00 00 00       	mov    $0x8,%eax
  8011f5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8011f8:	8b 55 08             	mov    0x8(%ebp),%edx
  8011fb:	89 df                	mov    %ebx,%edi
  8011fd:	89 de                	mov    %ebx,%esi
  8011ff:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  801201:	85 c0                	test   %eax,%eax
  801203:	7e 28                	jle    80122d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801205:	89 44 24 10          	mov    %eax,0x10(%esp)
  801209:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  801210:	00 
  801211:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  801218:	00 
  801219:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801220:	00 
  801221:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  801228:	e8 d3 f1 ff ff       	call   800400 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80122d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801230:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801233:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801236:	89 ec                	mov    %ebp,%esp
  801238:	5d                   	pop    %ebp
  801239:	c3                   	ret    

0080123a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80123a:	55                   	push   %ebp
  80123b:	89 e5                	mov    %esp,%ebp
  80123d:	83 ec 38             	sub    $0x38,%esp
  801240:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801243:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801246:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801249:	bb 00 00 00 00       	mov    $0x0,%ebx
  80124e:	b8 06 00 00 00       	mov    $0x6,%eax
  801253:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801256:	8b 55 08             	mov    0x8(%ebp),%edx
  801259:	89 df                	mov    %ebx,%edi
  80125b:	89 de                	mov    %ebx,%esi
  80125d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80125f:	85 c0                	test   %eax,%eax
  801261:	7e 28                	jle    80128b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801263:	89 44 24 10          	mov    %eax,0x10(%esp)
  801267:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80126e:	00 
  80126f:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  801276:	00 
  801277:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80127e:	00 
  80127f:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  801286:	e8 75 f1 ff ff       	call   800400 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80128b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80128e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801291:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801294:	89 ec                	mov    %ebp,%esp
  801296:	5d                   	pop    %ebp
  801297:	c3                   	ret    

00801298 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801298:	55                   	push   %ebp
  801299:	89 e5                	mov    %esp,%ebp
  80129b:	83 ec 38             	sub    $0x38,%esp
  80129e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012a1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8012a4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8012a7:	b8 05 00 00 00       	mov    $0x5,%eax
  8012ac:	8b 75 18             	mov    0x18(%ebp),%esi
  8012af:	8b 7d 14             	mov    0x14(%ebp),%edi
  8012b2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8012b5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8012b8:	8b 55 08             	mov    0x8(%ebp),%edx
  8012bb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8012bd:	85 c0                	test   %eax,%eax
  8012bf:	7e 28                	jle    8012e9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8012c1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012c5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8012cc:	00 
  8012cd:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  8012d4:	00 
  8012d5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8012dc:	00 
  8012dd:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  8012e4:	e8 17 f1 ff ff       	call   800400 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  8012e9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8012ec:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8012ef:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8012f2:	89 ec                	mov    %ebp,%esp
  8012f4:	5d                   	pop    %ebp
  8012f5:	c3                   	ret    

008012f6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  8012f6:	55                   	push   %ebp
  8012f7:	89 e5                	mov    %esp,%ebp
  8012f9:	83 ec 38             	sub    $0x38,%esp
  8012fc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8012ff:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801302:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801305:	be 00 00 00 00       	mov    $0x0,%esi
  80130a:	b8 04 00 00 00       	mov    $0x4,%eax
  80130f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801312:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801315:	8b 55 08             	mov    0x8(%ebp),%edx
  801318:	89 f7                	mov    %esi,%edi
  80131a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80131c:	85 c0                	test   %eax,%eax
  80131e:	7e 28                	jle    801348 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801320:	89 44 24 10          	mov    %eax,0x10(%esp)
  801324:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80132b:	00 
  80132c:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  801333:	00 
  801334:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80133b:	00 
  80133c:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  801343:	e8 b8 f0 ff ff       	call   800400 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801348:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80134b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80134e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801351:	89 ec                	mov    %ebp,%esp
  801353:	5d                   	pop    %ebp
  801354:	c3                   	ret    

00801355 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801355:	55                   	push   %ebp
  801356:	89 e5                	mov    %esp,%ebp
  801358:	83 ec 0c             	sub    $0xc,%esp
  80135b:	89 1c 24             	mov    %ebx,(%esp)
  80135e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801362:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801366:	ba 00 00 00 00       	mov    $0x0,%edx
  80136b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801370:	89 d1                	mov    %edx,%ecx
  801372:	89 d3                	mov    %edx,%ebx
  801374:	89 d7                	mov    %edx,%edi
  801376:	89 d6                	mov    %edx,%esi
  801378:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80137a:	8b 1c 24             	mov    (%esp),%ebx
  80137d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801381:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801385:	89 ec                	mov    %ebp,%esp
  801387:	5d                   	pop    %ebp
  801388:	c3                   	ret    

00801389 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801389:	55                   	push   %ebp
  80138a:	89 e5                	mov    %esp,%ebp
  80138c:	83 ec 0c             	sub    $0xc,%esp
  80138f:	89 1c 24             	mov    %ebx,(%esp)
  801392:	89 74 24 04          	mov    %esi,0x4(%esp)
  801396:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80139a:	ba 00 00 00 00       	mov    $0x0,%edx
  80139f:	b8 02 00 00 00       	mov    $0x2,%eax
  8013a4:	89 d1                	mov    %edx,%ecx
  8013a6:	89 d3                	mov    %edx,%ebx
  8013a8:	89 d7                	mov    %edx,%edi
  8013aa:	89 d6                	mov    %edx,%esi
  8013ac:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8013ae:	8b 1c 24             	mov    (%esp),%ebx
  8013b1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8013b5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8013b9:	89 ec                	mov    %ebp,%esp
  8013bb:	5d                   	pop    %ebp
  8013bc:	c3                   	ret    

008013bd <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8013bd:	55                   	push   %ebp
  8013be:	89 e5                	mov    %esp,%ebp
  8013c0:	83 ec 38             	sub    $0x38,%esp
  8013c3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8013c6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8013c9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8013cc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8013d1:	b8 03 00 00 00       	mov    $0x3,%eax
  8013d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8013d9:	89 cb                	mov    %ecx,%ebx
  8013db:	89 cf                	mov    %ecx,%edi
  8013dd:	89 ce                	mov    %ecx,%esi
  8013df:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8013e1:	85 c0                	test   %eax,%eax
  8013e3:	7e 28                	jle    80140d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8013e5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8013e9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8013f0:	00 
  8013f1:	c7 44 24 08 4b 30 80 	movl   $0x80304b,0x8(%esp)
  8013f8:	00 
  8013f9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801400:	00 
  801401:	c7 04 24 68 30 80 00 	movl   $0x803068,(%esp)
  801408:	e8 f3 ef ff ff       	call   800400 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80140d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801410:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801413:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801416:	89 ec                	mov    %ebp,%esp
  801418:	5d                   	pop    %ebp
  801419:	c3                   	ret    
  80141a:	00 00                	add    %al,(%eax)
  80141c:	00 00                	add    %al,(%eax)
	...

00801420 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801420:	55                   	push   %ebp
  801421:	89 e5                	mov    %esp,%ebp
  801423:	8b 45 08             	mov    0x8(%ebp),%eax
  801426:	05 00 00 00 30       	add    $0x30000000,%eax
  80142b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80142e:	5d                   	pop    %ebp
  80142f:	c3                   	ret    

00801430 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801430:	55                   	push   %ebp
  801431:	89 e5                	mov    %esp,%ebp
  801433:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801436:	8b 45 08             	mov    0x8(%ebp),%eax
  801439:	89 04 24             	mov    %eax,(%esp)
  80143c:	e8 df ff ff ff       	call   801420 <fd2num>
  801441:	05 20 00 0d 00       	add    $0xd0020,%eax
  801446:	c1 e0 0c             	shl    $0xc,%eax
}
  801449:	c9                   	leave  
  80144a:	c3                   	ret    

0080144b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80144b:	55                   	push   %ebp
  80144c:	89 e5                	mov    %esp,%ebp
  80144e:	57                   	push   %edi
  80144f:	56                   	push   %esi
  801450:	53                   	push   %ebx
  801451:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801454:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801459:	a8 01                	test   $0x1,%al
  80145b:	74 36                	je     801493 <fd_alloc+0x48>
  80145d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801462:	a8 01                	test   $0x1,%al
  801464:	74 2d                	je     801493 <fd_alloc+0x48>
  801466:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80146b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801470:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801475:	89 c3                	mov    %eax,%ebx
  801477:	89 c2                	mov    %eax,%edx
  801479:	c1 ea 16             	shr    $0x16,%edx
  80147c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80147f:	f6 c2 01             	test   $0x1,%dl
  801482:	74 14                	je     801498 <fd_alloc+0x4d>
  801484:	89 c2                	mov    %eax,%edx
  801486:	c1 ea 0c             	shr    $0xc,%edx
  801489:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80148c:	f6 c2 01             	test   $0x1,%dl
  80148f:	75 10                	jne    8014a1 <fd_alloc+0x56>
  801491:	eb 05                	jmp    801498 <fd_alloc+0x4d>
  801493:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801498:	89 1f                	mov    %ebx,(%edi)
  80149a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80149f:	eb 17                	jmp    8014b8 <fd_alloc+0x6d>
  8014a1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8014a6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8014ab:	75 c8                	jne    801475 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8014ad:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8014b3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8014b8:	5b                   	pop    %ebx
  8014b9:	5e                   	pop    %esi
  8014ba:	5f                   	pop    %edi
  8014bb:	5d                   	pop    %ebp
  8014bc:	c3                   	ret    

008014bd <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8014bd:	55                   	push   %ebp
  8014be:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8014c0:	8b 45 08             	mov    0x8(%ebp),%eax
  8014c3:	83 f8 1f             	cmp    $0x1f,%eax
  8014c6:	77 36                	ja     8014fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8014c8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8014cd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8014d0:	89 c2                	mov    %eax,%edx
  8014d2:	c1 ea 16             	shr    $0x16,%edx
  8014d5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8014dc:	f6 c2 01             	test   $0x1,%dl
  8014df:	74 1d                	je     8014fe <fd_lookup+0x41>
  8014e1:	89 c2                	mov    %eax,%edx
  8014e3:	c1 ea 0c             	shr    $0xc,%edx
  8014e6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8014ed:	f6 c2 01             	test   $0x1,%dl
  8014f0:	74 0c                	je     8014fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8014f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8014f5:	89 02                	mov    %eax,(%edx)
  8014f7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8014fc:	eb 05                	jmp    801503 <fd_lookup+0x46>
  8014fe:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801503:	5d                   	pop    %ebp
  801504:	c3                   	ret    

00801505 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801505:	55                   	push   %ebp
  801506:	89 e5                	mov    %esp,%ebp
  801508:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80150b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80150e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801512:	8b 45 08             	mov    0x8(%ebp),%eax
  801515:	89 04 24             	mov    %eax,(%esp)
  801518:	e8 a0 ff ff ff       	call   8014bd <fd_lookup>
  80151d:	85 c0                	test   %eax,%eax
  80151f:	78 0e                	js     80152f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801521:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801524:	8b 55 0c             	mov    0xc(%ebp),%edx
  801527:	89 50 04             	mov    %edx,0x4(%eax)
  80152a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80152f:	c9                   	leave  
  801530:	c3                   	ret    

00801531 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801531:	55                   	push   %ebp
  801532:	89 e5                	mov    %esp,%ebp
  801534:	56                   	push   %esi
  801535:	53                   	push   %ebx
  801536:	83 ec 10             	sub    $0x10,%esp
  801539:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80153c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80153f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801544:	b8 04 70 80 00       	mov    $0x807004,%eax
  801549:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80154f:	75 11                	jne    801562 <dev_lookup+0x31>
  801551:	eb 04                	jmp    801557 <dev_lookup+0x26>
  801553:	39 08                	cmp    %ecx,(%eax)
  801555:	75 10                	jne    801567 <dev_lookup+0x36>
			*dev = devtab[i];
  801557:	89 03                	mov    %eax,(%ebx)
  801559:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80155e:	66 90                	xchg   %ax,%ax
  801560:	eb 36                	jmp    801598 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801562:	be f4 30 80 00       	mov    $0x8030f4,%esi
  801567:	83 c2 01             	add    $0x1,%edx
  80156a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80156d:	85 c0                	test   %eax,%eax
  80156f:	75 e2                	jne    801553 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801571:	a1 80 74 80 00       	mov    0x807480,%eax
  801576:	8b 40 4c             	mov    0x4c(%eax),%eax
  801579:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80157d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801581:	c7 04 24 78 30 80 00 	movl   $0x803078,(%esp)
  801588:	e8 38 ef ff ff       	call   8004c5 <cprintf>
	*dev = 0;
  80158d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801593:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801598:	83 c4 10             	add    $0x10,%esp
  80159b:	5b                   	pop    %ebx
  80159c:	5e                   	pop    %esi
  80159d:	5d                   	pop    %ebp
  80159e:	c3                   	ret    

0080159f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80159f:	55                   	push   %ebp
  8015a0:	89 e5                	mov    %esp,%ebp
  8015a2:	53                   	push   %ebx
  8015a3:	83 ec 24             	sub    $0x24,%esp
  8015a6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8015a9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8015ac:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015b0:	8b 45 08             	mov    0x8(%ebp),%eax
  8015b3:	89 04 24             	mov    %eax,(%esp)
  8015b6:	e8 02 ff ff ff       	call   8014bd <fd_lookup>
  8015bb:	85 c0                	test   %eax,%eax
  8015bd:	78 53                	js     801612 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8015bf:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8015c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8015c6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8015c9:	8b 00                	mov    (%eax),%eax
  8015cb:	89 04 24             	mov    %eax,(%esp)
  8015ce:	e8 5e ff ff ff       	call   801531 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8015d3:	85 c0                	test   %eax,%eax
  8015d5:	78 3b                	js     801612 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8015d7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8015dc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8015df:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8015e3:	74 2d                	je     801612 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8015e5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8015e8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8015ef:	00 00 00 
	stat->st_isdir = 0;
  8015f2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8015f9:	00 00 00 
	stat->st_dev = dev;
  8015fc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8015ff:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801605:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801609:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80160c:	89 14 24             	mov    %edx,(%esp)
  80160f:	ff 50 14             	call   *0x14(%eax)
}
  801612:	83 c4 24             	add    $0x24,%esp
  801615:	5b                   	pop    %ebx
  801616:	5d                   	pop    %ebp
  801617:	c3                   	ret    

00801618 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801618:	55                   	push   %ebp
  801619:	89 e5                	mov    %esp,%ebp
  80161b:	53                   	push   %ebx
  80161c:	83 ec 24             	sub    $0x24,%esp
  80161f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801622:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801625:	89 44 24 04          	mov    %eax,0x4(%esp)
  801629:	89 1c 24             	mov    %ebx,(%esp)
  80162c:	e8 8c fe ff ff       	call   8014bd <fd_lookup>
  801631:	85 c0                	test   %eax,%eax
  801633:	78 5f                	js     801694 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801635:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801638:	89 44 24 04          	mov    %eax,0x4(%esp)
  80163c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80163f:	8b 00                	mov    (%eax),%eax
  801641:	89 04 24             	mov    %eax,(%esp)
  801644:	e8 e8 fe ff ff       	call   801531 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801649:	85 c0                	test   %eax,%eax
  80164b:	78 47                	js     801694 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80164d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801650:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801654:	75 23                	jne    801679 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801656:	a1 80 74 80 00       	mov    0x807480,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80165b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80165e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801662:	89 44 24 04          	mov    %eax,0x4(%esp)
  801666:	c7 04 24 98 30 80 00 	movl   $0x803098,(%esp)
  80166d:	e8 53 ee ff ff       	call   8004c5 <cprintf>
  801672:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801677:	eb 1b                	jmp    801694 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801679:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80167c:	8b 48 18             	mov    0x18(%eax),%ecx
  80167f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801684:	85 c9                	test   %ecx,%ecx
  801686:	74 0c                	je     801694 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801688:	8b 45 0c             	mov    0xc(%ebp),%eax
  80168b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80168f:	89 14 24             	mov    %edx,(%esp)
  801692:	ff d1                	call   *%ecx
}
  801694:	83 c4 24             	add    $0x24,%esp
  801697:	5b                   	pop    %ebx
  801698:	5d                   	pop    %ebp
  801699:	c3                   	ret    

0080169a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80169a:	55                   	push   %ebp
  80169b:	89 e5                	mov    %esp,%ebp
  80169d:	53                   	push   %ebx
  80169e:	83 ec 24             	sub    $0x24,%esp
  8016a1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016a4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016a7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016ab:	89 1c 24             	mov    %ebx,(%esp)
  8016ae:	e8 0a fe ff ff       	call   8014bd <fd_lookup>
  8016b3:	85 c0                	test   %eax,%eax
  8016b5:	78 66                	js     80171d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8016b7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016be:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8016c1:	8b 00                	mov    (%eax),%eax
  8016c3:	89 04 24             	mov    %eax,(%esp)
  8016c6:	e8 66 fe ff ff       	call   801531 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016cb:	85 c0                	test   %eax,%eax
  8016cd:	78 4e                	js     80171d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8016cf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8016d2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8016d6:	75 23                	jne    8016fb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8016d8:	a1 80 74 80 00       	mov    0x807480,%eax
  8016dd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8016e0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8016e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016e8:	c7 04 24 b9 30 80 00 	movl   $0x8030b9,(%esp)
  8016ef:	e8 d1 ed ff ff       	call   8004c5 <cprintf>
  8016f4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8016f9:	eb 22                	jmp    80171d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8016fb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016fe:	8b 48 0c             	mov    0xc(%eax),%ecx
  801701:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801706:	85 c9                	test   %ecx,%ecx
  801708:	74 13                	je     80171d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80170a:	8b 45 10             	mov    0x10(%ebp),%eax
  80170d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801711:	8b 45 0c             	mov    0xc(%ebp),%eax
  801714:	89 44 24 04          	mov    %eax,0x4(%esp)
  801718:	89 14 24             	mov    %edx,(%esp)
  80171b:	ff d1                	call   *%ecx
}
  80171d:	83 c4 24             	add    $0x24,%esp
  801720:	5b                   	pop    %ebx
  801721:	5d                   	pop    %ebp
  801722:	c3                   	ret    

00801723 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801723:	55                   	push   %ebp
  801724:	89 e5                	mov    %esp,%ebp
  801726:	57                   	push   %edi
  801727:	56                   	push   %esi
  801728:	53                   	push   %ebx
  801729:	83 ec 2c             	sub    $0x2c,%esp
  80172c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80172f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801732:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801735:	89 44 24 04          	mov    %eax,0x4(%esp)
  801739:	89 1c 24             	mov    %ebx,(%esp)
  80173c:	e8 7c fd ff ff       	call   8014bd <fd_lookup>
  801741:	85 c0                	test   %eax,%eax
  801743:	0f 88 b0 00 00 00    	js     8017f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801749:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80174c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801750:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801753:	8b 00                	mov    (%eax),%eax
  801755:	89 04 24             	mov    %eax,(%esp)
  801758:	e8 d4 fd ff ff       	call   801531 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80175d:	85 c0                	test   %eax,%eax
  80175f:	0f 88 94 00 00 00    	js     8017f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801765:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801768:	8b 40 08             	mov    0x8(%eax),%eax
  80176b:	83 e0 03             	and    $0x3,%eax
  80176e:	83 f8 01             	cmp    $0x1,%eax
  801771:	75 23                	jne    801796 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801773:	a1 80 74 80 00       	mov    0x807480,%eax
  801778:	8b 40 4c             	mov    0x4c(%eax),%eax
  80177b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80177f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801783:	c7 04 24 d6 30 80 00 	movl   $0x8030d6,(%esp)
  80178a:	e8 36 ed ff ff       	call   8004c5 <cprintf>
  80178f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801794:	eb 63                	jmp    8017f9 <read+0xd6>
	}
	if (!dev->dev_read)
  801796:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80179b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80179e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8017a2:	74 55                	je     8017f9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8017a4:	ba 00 00 00 00       	mov    $0x0,%edx
  8017a9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8017ae:	b8 00 00 00 00       	mov    $0x0,%eax
  8017b3:	85 f6                	test   %esi,%esi
  8017b5:	74 42                	je     8017f9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8017b7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8017bc:	89 f0                	mov    %esi,%eax
  8017be:	29 d0                	sub    %edx,%eax
  8017c0:	89 c1                	mov    %eax,%ecx
  8017c2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8017c8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8017cd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8017d0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8017d4:	03 55 0c             	add    0xc(%ebp),%edx
  8017d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8017db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8017de:	89 04 24             	mov    %eax,(%esp)
  8017e1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8017e4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8017e7:	85 c0                	test   %eax,%eax
  8017e9:	78 0e                	js     8017f9 <read+0xd6>
			return m;
		if (m == 0)
  8017eb:	85 c0                	test   %eax,%eax
  8017ed:	74 08                	je     8017f7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8017ef:	01 c3                	add    %eax,%ebx
  8017f1:	89 da                	mov    %ebx,%edx
  8017f3:	39 f3                	cmp    %esi,%ebx
  8017f5:	72 c5                	jb     8017bc <read+0x99>
  8017f7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8017f9:	83 c4 2c             	add    $0x2c,%esp
  8017fc:	5b                   	pop    %ebx
  8017fd:	5e                   	pop    %esi
  8017fe:	5f                   	pop    %edi
  8017ff:	5d                   	pop    %ebp
  801800:	c3                   	ret    

00801801 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801801:	55                   	push   %ebp
  801802:	89 e5                	mov    %esp,%ebp
  801804:	57                   	push   %edi
  801805:	56                   	push   %esi
  801806:	53                   	push   %ebx
  801807:	83 ec 1c             	sub    $0x1c,%esp
  80180a:	8b 7d 08             	mov    0x8(%ebp),%edi
  80180d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801810:	ba 00 00 00 00       	mov    $0x0,%edx
  801815:	bb 00 00 00 00       	mov    $0x0,%ebx
  80181a:	b8 00 00 00 00       	mov    $0x0,%eax
  80181f:	85 f6                	test   %esi,%esi
  801821:	74 29                	je     80184c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801823:	89 f0                	mov    %esi,%eax
  801825:	29 d0                	sub    %edx,%eax
  801827:	89 44 24 08          	mov    %eax,0x8(%esp)
  80182b:	03 55 0c             	add    0xc(%ebp),%edx
  80182e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801832:	89 3c 24             	mov    %edi,(%esp)
  801835:	e8 e9 fe ff ff       	call   801723 <read>
		if (m < 0)
  80183a:	85 c0                	test   %eax,%eax
  80183c:	78 0e                	js     80184c <readn+0x4b>
			return m;
		if (m == 0)
  80183e:	85 c0                	test   %eax,%eax
  801840:	74 08                	je     80184a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801842:	01 c3                	add    %eax,%ebx
  801844:	89 da                	mov    %ebx,%edx
  801846:	39 f3                	cmp    %esi,%ebx
  801848:	72 d9                	jb     801823 <readn+0x22>
  80184a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80184c:	83 c4 1c             	add    $0x1c,%esp
  80184f:	5b                   	pop    %ebx
  801850:	5e                   	pop    %esi
  801851:	5f                   	pop    %edi
  801852:	5d                   	pop    %ebp
  801853:	c3                   	ret    

00801854 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801854:	55                   	push   %ebp
  801855:	89 e5                	mov    %esp,%ebp
  801857:	83 ec 28             	sub    $0x28,%esp
  80185a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80185d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801860:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801863:	89 34 24             	mov    %esi,(%esp)
  801866:	e8 b5 fb ff ff       	call   801420 <fd2num>
  80186b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80186e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801872:	89 04 24             	mov    %eax,(%esp)
  801875:	e8 43 fc ff ff       	call   8014bd <fd_lookup>
  80187a:	89 c3                	mov    %eax,%ebx
  80187c:	85 c0                	test   %eax,%eax
  80187e:	78 05                	js     801885 <fd_close+0x31>
  801880:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801883:	74 0e                	je     801893 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801885:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801889:	b8 00 00 00 00       	mov    $0x0,%eax
  80188e:	0f 44 d8             	cmove  %eax,%ebx
  801891:	eb 3d                	jmp    8018d0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801893:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801896:	89 44 24 04          	mov    %eax,0x4(%esp)
  80189a:	8b 06                	mov    (%esi),%eax
  80189c:	89 04 24             	mov    %eax,(%esp)
  80189f:	e8 8d fc ff ff       	call   801531 <dev_lookup>
  8018a4:	89 c3                	mov    %eax,%ebx
  8018a6:	85 c0                	test   %eax,%eax
  8018a8:	78 16                	js     8018c0 <fd_close+0x6c>
		if (dev->dev_close)
  8018aa:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8018ad:	8b 40 10             	mov    0x10(%eax),%eax
  8018b0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8018b5:	85 c0                	test   %eax,%eax
  8018b7:	74 07                	je     8018c0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8018b9:	89 34 24             	mov    %esi,(%esp)
  8018bc:	ff d0                	call   *%eax
  8018be:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8018c0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8018c4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018cb:	e8 6a f9 ff ff       	call   80123a <sys_page_unmap>
	return r;
}
  8018d0:	89 d8                	mov    %ebx,%eax
  8018d2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8018d5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8018d8:	89 ec                	mov    %ebp,%esp
  8018da:	5d                   	pop    %ebp
  8018db:	c3                   	ret    

008018dc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8018dc:	55                   	push   %ebp
  8018dd:	89 e5                	mov    %esp,%ebp
  8018df:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8018e2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8018e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8018e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8018ec:	89 04 24             	mov    %eax,(%esp)
  8018ef:	e8 c9 fb ff ff       	call   8014bd <fd_lookup>
  8018f4:	85 c0                	test   %eax,%eax
  8018f6:	78 13                	js     80190b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8018f8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8018ff:	00 
  801900:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801903:	89 04 24             	mov    %eax,(%esp)
  801906:	e8 49 ff ff ff       	call   801854 <fd_close>
}
  80190b:	c9                   	leave  
  80190c:	c3                   	ret    

0080190d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  80190d:	55                   	push   %ebp
  80190e:	89 e5                	mov    %esp,%ebp
  801910:	83 ec 18             	sub    $0x18,%esp
  801913:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801916:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801919:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801920:	00 
  801921:	8b 45 08             	mov    0x8(%ebp),%eax
  801924:	89 04 24             	mov    %eax,(%esp)
  801927:	e8 80 03 00 00       	call   801cac <open>
  80192c:	89 c3                	mov    %eax,%ebx
  80192e:	85 c0                	test   %eax,%eax
  801930:	78 1b                	js     80194d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801932:	8b 45 0c             	mov    0xc(%ebp),%eax
  801935:	89 44 24 04          	mov    %eax,0x4(%esp)
  801939:	89 1c 24             	mov    %ebx,(%esp)
  80193c:	e8 5e fc ff ff       	call   80159f <fstat>
  801941:	89 c6                	mov    %eax,%esi
	close(fd);
  801943:	89 1c 24             	mov    %ebx,(%esp)
  801946:	e8 91 ff ff ff       	call   8018dc <close>
  80194b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80194d:	89 d8                	mov    %ebx,%eax
  80194f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801952:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801955:	89 ec                	mov    %ebp,%esp
  801957:	5d                   	pop    %ebp
  801958:	c3                   	ret    

00801959 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801959:	55                   	push   %ebp
  80195a:	89 e5                	mov    %esp,%ebp
  80195c:	53                   	push   %ebx
  80195d:	83 ec 14             	sub    $0x14,%esp
  801960:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801965:	89 1c 24             	mov    %ebx,(%esp)
  801968:	e8 6f ff ff ff       	call   8018dc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80196d:	83 c3 01             	add    $0x1,%ebx
  801970:	83 fb 20             	cmp    $0x20,%ebx
  801973:	75 f0                	jne    801965 <close_all+0xc>
		close(i);
}
  801975:	83 c4 14             	add    $0x14,%esp
  801978:	5b                   	pop    %ebx
  801979:	5d                   	pop    %ebp
  80197a:	c3                   	ret    

0080197b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80197b:	55                   	push   %ebp
  80197c:	89 e5                	mov    %esp,%ebp
  80197e:	83 ec 58             	sub    $0x58,%esp
  801981:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801984:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801987:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80198a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80198d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801990:	89 44 24 04          	mov    %eax,0x4(%esp)
  801994:	8b 45 08             	mov    0x8(%ebp),%eax
  801997:	89 04 24             	mov    %eax,(%esp)
  80199a:	e8 1e fb ff ff       	call   8014bd <fd_lookup>
  80199f:	89 c3                	mov    %eax,%ebx
  8019a1:	85 c0                	test   %eax,%eax
  8019a3:	0f 88 e0 00 00 00    	js     801a89 <dup+0x10e>
		return r;
	close(newfdnum);
  8019a9:	89 3c 24             	mov    %edi,(%esp)
  8019ac:	e8 2b ff ff ff       	call   8018dc <close>

	newfd = INDEX2FD(newfdnum);
  8019b1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  8019b7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  8019ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8019bd:	89 04 24             	mov    %eax,(%esp)
  8019c0:	e8 6b fa ff ff       	call   801430 <fd2data>
  8019c5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8019c7:	89 34 24             	mov    %esi,(%esp)
  8019ca:	e8 61 fa ff ff       	call   801430 <fd2data>
  8019cf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  8019d2:	89 da                	mov    %ebx,%edx
  8019d4:	89 d8                	mov    %ebx,%eax
  8019d6:	c1 e8 16             	shr    $0x16,%eax
  8019d9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8019e0:	a8 01                	test   $0x1,%al
  8019e2:	74 43                	je     801a27 <dup+0xac>
  8019e4:	c1 ea 0c             	shr    $0xc,%edx
  8019e7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8019ee:	a8 01                	test   $0x1,%al
  8019f0:	74 35                	je     801a27 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8019f2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8019f9:	25 07 0e 00 00       	and    $0xe07,%eax
  8019fe:	89 44 24 10          	mov    %eax,0x10(%esp)
  801a02:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801a05:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801a09:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801a10:	00 
  801a11:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a15:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a1c:	e8 77 f8 ff ff       	call   801298 <sys_page_map>
  801a21:	89 c3                	mov    %eax,%ebx
  801a23:	85 c0                	test   %eax,%eax
  801a25:	78 3f                	js     801a66 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801a27:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801a2a:	89 c2                	mov    %eax,%edx
  801a2c:	c1 ea 0c             	shr    $0xc,%edx
  801a2f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801a36:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801a3c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801a40:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801a44:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801a4b:	00 
  801a4c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a50:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a57:	e8 3c f8 ff ff       	call   801298 <sys_page_map>
  801a5c:	89 c3                	mov    %eax,%ebx
  801a5e:	85 c0                	test   %eax,%eax
  801a60:	78 04                	js     801a66 <dup+0xeb>
  801a62:	89 fb                	mov    %edi,%ebx
  801a64:	eb 23                	jmp    801a89 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801a66:	89 74 24 04          	mov    %esi,0x4(%esp)
  801a6a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a71:	e8 c4 f7 ff ff       	call   80123a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801a76:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801a79:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a7d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801a84:	e8 b1 f7 ff ff       	call   80123a <sys_page_unmap>
	return r;
}
  801a89:	89 d8                	mov    %ebx,%eax
  801a8b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801a8e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801a91:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801a94:	89 ec                	mov    %ebp,%esp
  801a96:	5d                   	pop    %ebp
  801a97:	c3                   	ret    

00801a98 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801a98:	55                   	push   %ebp
  801a99:	89 e5                	mov    %esp,%ebp
  801a9b:	53                   	push   %ebx
  801a9c:	83 ec 14             	sub    $0x14,%esp
  801a9f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801aa1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801aa7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801aae:	00 
  801aaf:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801ab6:	00 
  801ab7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801abb:	89 14 24             	mov    %edx,(%esp)
  801abe:	e8 2d 0e 00 00       	call   8028f0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801ac3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801aca:	00 
  801acb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801acf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801ad6:	e8 87 0e 00 00       	call   802962 <ipc_recv>
}
  801adb:	83 c4 14             	add    $0x14,%esp
  801ade:	5b                   	pop    %ebx
  801adf:	5d                   	pop    %ebp
  801ae0:	c3                   	ret    

00801ae1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801ae1:	55                   	push   %ebp
  801ae2:	89 e5                	mov    %esp,%ebp
  801ae4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801ae7:	8b 45 08             	mov    0x8(%ebp),%eax
  801aea:	8b 40 0c             	mov    0xc(%eax),%eax
  801aed:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801af2:	8b 45 0c             	mov    0xc(%ebp),%eax
  801af5:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801afa:	ba 00 00 00 00       	mov    $0x0,%edx
  801aff:	b8 02 00 00 00       	mov    $0x2,%eax
  801b04:	e8 8f ff ff ff       	call   801a98 <fsipc>
}
  801b09:	c9                   	leave  
  801b0a:	c3                   	ret    

00801b0b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801b0b:	55                   	push   %ebp
  801b0c:	89 e5                	mov    %esp,%ebp
  801b0e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801b11:	8b 45 08             	mov    0x8(%ebp),%eax
  801b14:	8b 40 0c             	mov    0xc(%eax),%eax
  801b17:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801b1c:	ba 00 00 00 00       	mov    $0x0,%edx
  801b21:	b8 06 00 00 00       	mov    $0x6,%eax
  801b26:	e8 6d ff ff ff       	call   801a98 <fsipc>
}
  801b2b:	c9                   	leave  
  801b2c:	c3                   	ret    

00801b2d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801b2d:	55                   	push   %ebp
  801b2e:	89 e5                	mov    %esp,%ebp
  801b30:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801b33:	ba 00 00 00 00       	mov    $0x0,%edx
  801b38:	b8 08 00 00 00       	mov    $0x8,%eax
  801b3d:	e8 56 ff ff ff       	call   801a98 <fsipc>
}
  801b42:	c9                   	leave  
  801b43:	c3                   	ret    

00801b44 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801b44:	55                   	push   %ebp
  801b45:	89 e5                	mov    %esp,%ebp
  801b47:	53                   	push   %ebx
  801b48:	83 ec 14             	sub    $0x14,%esp
  801b4b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801b4e:	8b 45 08             	mov    0x8(%ebp),%eax
  801b51:	8b 40 0c             	mov    0xc(%eax),%eax
  801b54:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801b59:	ba 00 00 00 00       	mov    $0x0,%edx
  801b5e:	b8 05 00 00 00       	mov    $0x5,%eax
  801b63:	e8 30 ff ff ff       	call   801a98 <fsipc>
  801b68:	85 c0                	test   %eax,%eax
  801b6a:	78 2b                	js     801b97 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801b6c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801b73:	00 
  801b74:	89 1c 24             	mov    %ebx,(%esp)
  801b77:	e8 1e f0 ff ff       	call   800b9a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801b7c:	a1 80 40 80 00       	mov    0x804080,%eax
  801b81:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801b87:	a1 84 40 80 00       	mov    0x804084,%eax
  801b8c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801b92:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801b97:	83 c4 14             	add    $0x14,%esp
  801b9a:	5b                   	pop    %ebx
  801b9b:	5d                   	pop    %ebp
  801b9c:	c3                   	ret    

00801b9d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801b9d:	55                   	push   %ebp
  801b9e:	89 e5                	mov    %esp,%ebp
  801ba0:	53                   	push   %ebx
  801ba1:	83 ec 14             	sub    $0x14,%esp
  801ba4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ba7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801baa:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801bad:	85 c0                	test   %eax,%eax
  801baf:	74 44                	je     801bf5 <devfile_write+0x58>
  801bb1:	85 d2                	test   %edx,%edx
  801bb3:	74 40                	je     801bf5 <devfile_write+0x58>
  801bb5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801bbb:	77 38                	ja     801bf5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801bbd:	8b 40 0c             	mov    0xc(%eax),%eax
  801bc0:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801bc5:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801bcb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801bcf:	89 54 24 04          	mov    %edx,0x4(%esp)
  801bd3:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801bda:	e8 76 f1 ff ff       	call   800d55 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801bdf:	ba 00 00 00 00       	mov    $0x0,%edx
  801be4:	b8 04 00 00 00       	mov    $0x4,%eax
  801be9:	e8 aa fe ff ff       	call   801a98 <fsipc>
        return r;
    return n;
  801bee:	85 c0                	test   %eax,%eax
  801bf0:	0f 49 c3             	cmovns %ebx,%eax
  801bf3:	eb 05                	jmp    801bfa <devfile_write+0x5d>
  801bf5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801bfa:	83 c4 14             	add    $0x14,%esp
  801bfd:	5b                   	pop    %ebx
  801bfe:	5d                   	pop    %ebp
  801bff:	c3                   	ret    

00801c00 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801c00:	55                   	push   %ebp
  801c01:	89 e5                	mov    %esp,%ebp
  801c03:	83 ec 18             	sub    $0x18,%esp
  801c06:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801c09:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801c0c:	8b 45 08             	mov    0x8(%ebp),%eax
  801c0f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801c12:	85 c0                	test   %eax,%eax
  801c14:	74 04                	je     801c1a <devfile_read+0x1a>
  801c16:	85 f6                	test   %esi,%esi
  801c18:	75 07                	jne    801c21 <devfile_read+0x21>
  801c1a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801c1f:	eb 39                	jmp    801c5a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801c21:	8b 40 0c             	mov    0xc(%eax),%eax
  801c24:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801c29:	8b 45 10             	mov    0x10(%ebp),%eax
  801c2c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801c31:	ba 00 00 00 00       	mov    $0x0,%edx
  801c36:	b8 03 00 00 00       	mov    $0x3,%eax
  801c3b:	e8 58 fe ff ff       	call   801a98 <fsipc>
  801c40:	89 c3                	mov    %eax,%ebx
  801c42:	85 c0                	test   %eax,%eax
  801c44:	78 14                	js     801c5a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801c46:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c4a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801c51:	00 
  801c52:	89 34 24             	mov    %esi,(%esp)
  801c55:	e8 fb f0 ff ff       	call   800d55 <memmove>
  return r;
}
  801c5a:	89 d8                	mov    %ebx,%eax
  801c5c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801c5f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801c62:	89 ec                	mov    %ebp,%esp
  801c64:	5d                   	pop    %ebp
  801c65:	c3                   	ret    

00801c66 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801c66:	55                   	push   %ebp
  801c67:	89 e5                	mov    %esp,%ebp
  801c69:	53                   	push   %ebx
  801c6a:	83 ec 14             	sub    $0x14,%esp
  801c6d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801c70:	89 1c 24             	mov    %ebx,(%esp)
  801c73:	e8 d8 ee ff ff       	call   800b50 <strlen>
  801c78:	89 c2                	mov    %eax,%edx
  801c7a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801c7f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801c85:	7f 1f                	jg     801ca6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801c87:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801c8b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801c92:	e8 03 ef ff ff       	call   800b9a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801c97:	ba 00 00 00 00       	mov    $0x0,%edx
  801c9c:	b8 07 00 00 00       	mov    $0x7,%eax
  801ca1:	e8 f2 fd ff ff       	call   801a98 <fsipc>
}
  801ca6:	83 c4 14             	add    $0x14,%esp
  801ca9:	5b                   	pop    %ebx
  801caa:	5d                   	pop    %ebp
  801cab:	c3                   	ret    

00801cac <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801cac:	55                   	push   %ebp
  801cad:	89 e5                	mov    %esp,%ebp
  801caf:	83 ec 28             	sub    $0x28,%esp
  801cb2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801cb5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801cb8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801cbb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801cc0:	85 f6                	test   %esi,%esi
  801cc2:	74 65                	je     801d29 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801cc4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801ccb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801cce:	89 04 24             	mov    %eax,(%esp)
  801cd1:	e8 75 f7 ff ff       	call   80144b <fd_alloc>
  801cd6:	89 c3                	mov    %eax,%ebx
  801cd8:	85 c0                	test   %eax,%eax
  801cda:	78 4d                	js     801d29 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801cdc:	89 74 24 04          	mov    %esi,0x4(%esp)
  801ce0:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801ce7:	e8 ae ee ff ff       	call   800b9a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801cec:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cef:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801cf4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801cf7:	b8 01 00 00 00       	mov    $0x1,%eax
  801cfc:	e8 97 fd ff ff       	call   801a98 <fsipc>
  801d01:	89 c3                	mov    %eax,%ebx
  801d03:	85 c0                	test   %eax,%eax
  801d05:	79 15                	jns    801d1c <open+0x70>
    fd_close(f, 0);
  801d07:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801d0e:	00 
  801d0f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d12:	89 04 24             	mov    %eax,(%esp)
  801d15:	e8 3a fb ff ff       	call   801854 <fd_close>
    return r;
  801d1a:	eb 0d                	jmp    801d29 <open+0x7d>
  }
  return fd2num(f);
  801d1c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d1f:	89 04 24             	mov    %eax,(%esp)
  801d22:	e8 f9 f6 ff ff       	call   801420 <fd2num>
  801d27:	89 c3                	mov    %eax,%ebx
}
  801d29:	89 d8                	mov    %ebx,%eax
  801d2b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801d2e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801d31:	89 ec                	mov    %ebp,%esp
  801d33:	5d                   	pop    %ebp
  801d34:	c3                   	ret    
  801d35:	00 00                	add    %al,(%eax)
	...

00801d38 <writebuf>:
};


static void
writebuf(struct printbuf *b)
{
  801d38:	55                   	push   %ebp
  801d39:	89 e5                	mov    %esp,%ebp
  801d3b:	53                   	push   %ebx
  801d3c:	83 ec 14             	sub    $0x14,%esp
  801d3f:	89 c3                	mov    %eax,%ebx
	if (b->error > 0) {
  801d41:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  801d45:	7e 31                	jle    801d78 <writebuf+0x40>
		ssize_t result = write(b->fd, b->buf, b->idx);
  801d47:	8b 40 04             	mov    0x4(%eax),%eax
  801d4a:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d4e:	8d 43 10             	lea    0x10(%ebx),%eax
  801d51:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d55:	8b 03                	mov    (%ebx),%eax
  801d57:	89 04 24             	mov    %eax,(%esp)
  801d5a:	e8 3b f9 ff ff       	call   80169a <write>
		if (result > 0)
  801d5f:	85 c0                	test   %eax,%eax
  801d61:	7e 03                	jle    801d66 <writebuf+0x2e>
			b->result += result;
  801d63:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  801d66:	3b 43 04             	cmp    0x4(%ebx),%eax
  801d69:	74 0d                	je     801d78 <writebuf+0x40>
			b->error = (result < 0 ? result : 0);
  801d6b:	85 c0                	test   %eax,%eax
  801d6d:	ba 00 00 00 00       	mov    $0x0,%edx
  801d72:	0f 4f c2             	cmovg  %edx,%eax
  801d75:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  801d78:	83 c4 14             	add    $0x14,%esp
  801d7b:	5b                   	pop    %ebx
  801d7c:	5d                   	pop    %ebp
  801d7d:	c3                   	ret    

00801d7e <vfprintf>:
	}
}

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  801d7e:	55                   	push   %ebp
  801d7f:	89 e5                	mov    %esp,%ebp
  801d81:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.fd = fd;
  801d87:	8b 45 08             	mov    0x8(%ebp),%eax
  801d8a:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  801d90:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  801d97:	00 00 00 
	b.result = 0;
  801d9a:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801da1:	00 00 00 
	b.error = 1;
  801da4:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  801dab:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  801dae:	8b 45 10             	mov    0x10(%ebp),%eax
  801db1:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801db5:	8b 45 0c             	mov    0xc(%ebp),%eax
  801db8:	89 44 24 08          	mov    %eax,0x8(%esp)
  801dbc:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801dc2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801dc6:	c7 04 24 3a 1e 80 00 	movl   $0x801e3a,(%esp)
  801dcd:	e8 ab e8 ff ff       	call   80067d <vprintfmt>
	if (b.idx > 0)
  801dd2:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  801dd9:	7e 0b                	jle    801de6 <vfprintf+0x68>
		writebuf(&b);
  801ddb:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801de1:	e8 52 ff ff ff       	call   801d38 <writebuf>

	return (b.result ? b.result : b.error);
  801de6:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801dec:	85 c0                	test   %eax,%eax
  801dee:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  801df5:	c9                   	leave  
  801df6:	c3                   	ret    

00801df7 <printf>:
	return cnt;
}

int
printf(const char *fmt, ...)
{
  801df7:	55                   	push   %ebp
  801df8:	89 e5                	mov    %esp,%ebp
  801dfa:	83 ec 18             	sub    $0x18,%esp

	return cnt;
}

int
printf(const char *fmt, ...)
  801dfd:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(1, fmt, ap);
  801e00:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e04:	8b 45 08             	mov    0x8(%ebp),%eax
  801e07:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e0b:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801e12:	e8 67 ff ff ff       	call   801d7e <vfprintf>
	va_end(ap);

	return cnt;
}
  801e17:	c9                   	leave  
  801e18:	c3                   	ret    

00801e19 <fprintf>:
	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
{
  801e19:	55                   	push   %ebp
  801e1a:	89 e5                	mov    %esp,%ebp
  801e1c:	83 ec 18             	sub    $0x18,%esp

	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
  801e1f:	8d 45 10             	lea    0x10(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(fd, fmt, ap);
  801e22:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e26:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e29:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e2d:	8b 45 08             	mov    0x8(%ebp),%eax
  801e30:	89 04 24             	mov    %eax,(%esp)
  801e33:	e8 46 ff ff ff       	call   801d7e <vfprintf>
	va_end(ap);

	return cnt;
}
  801e38:	c9                   	leave  
  801e39:	c3                   	ret    

00801e3a <putch>:
	}
}

static void
putch(int ch, void *thunk)
{
  801e3a:	55                   	push   %ebp
  801e3b:	89 e5                	mov    %esp,%ebp
  801e3d:	53                   	push   %ebx
  801e3e:	83 ec 04             	sub    $0x4,%esp
	struct printbuf *b = (struct printbuf *) thunk;
  801e41:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801e44:	8b 43 04             	mov    0x4(%ebx),%eax
  801e47:	8b 55 08             	mov    0x8(%ebp),%edx
  801e4a:	88 54 03 10          	mov    %dl,0x10(%ebx,%eax,1)
  801e4e:	83 c0 01             	add    $0x1,%eax
  801e51:	89 43 04             	mov    %eax,0x4(%ebx)
	if (b->idx == 256) {
  801e54:	3d 00 01 00 00       	cmp    $0x100,%eax
  801e59:	75 0e                	jne    801e69 <putch+0x2f>
		writebuf(b);
  801e5b:	89 d8                	mov    %ebx,%eax
  801e5d:	e8 d6 fe ff ff       	call   801d38 <writebuf>
		b->idx = 0;
  801e62:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
	}
}
  801e69:	83 c4 04             	add    $0x4,%esp
  801e6c:	5b                   	pop    %ebx
  801e6d:	5d                   	pop    %ebp
  801e6e:	c3                   	ret    
	...

00801e70 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801e70:	55                   	push   %ebp
  801e71:	89 e5                	mov    %esp,%ebp
  801e73:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801e76:	c7 44 24 04 08 31 80 	movl   $0x803108,0x4(%esp)
  801e7d:	00 
  801e7e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e81:	89 04 24             	mov    %eax,(%esp)
  801e84:	e8 11 ed ff ff       	call   800b9a <strcpy>
	return 0;
}
  801e89:	b8 00 00 00 00       	mov    $0x0,%eax
  801e8e:	c9                   	leave  
  801e8f:	c3                   	ret    

00801e90 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801e90:	55                   	push   %ebp
  801e91:	89 e5                	mov    %esp,%ebp
  801e93:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801e96:	8b 45 08             	mov    0x8(%ebp),%eax
  801e99:	8b 40 0c             	mov    0xc(%eax),%eax
  801e9c:	89 04 24             	mov    %eax,(%esp)
  801e9f:	e8 9d 02 00 00       	call   802141 <nsipc_close>
}
  801ea4:	c9                   	leave  
  801ea5:	c3                   	ret    

00801ea6 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801ea6:	55                   	push   %ebp
  801ea7:	89 e5                	mov    %esp,%ebp
  801ea9:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801eac:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801eb3:	00 
  801eb4:	8b 45 10             	mov    0x10(%ebp),%eax
  801eb7:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ebb:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ebe:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ec2:	8b 45 08             	mov    0x8(%ebp),%eax
  801ec5:	8b 40 0c             	mov    0xc(%eax),%eax
  801ec8:	89 04 24             	mov    %eax,(%esp)
  801ecb:	e8 ad 02 00 00       	call   80217d <nsipc_send>
}
  801ed0:	c9                   	leave  
  801ed1:	c3                   	ret    

00801ed2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801ed2:	55                   	push   %ebp
  801ed3:	89 e5                	mov    %esp,%ebp
  801ed5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801ed8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801edf:	00 
  801ee0:	8b 45 10             	mov    0x10(%ebp),%eax
  801ee3:	89 44 24 08          	mov    %eax,0x8(%esp)
  801ee7:	8b 45 0c             	mov    0xc(%ebp),%eax
  801eea:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eee:	8b 45 08             	mov    0x8(%ebp),%eax
  801ef1:	8b 40 0c             	mov    0xc(%eax),%eax
  801ef4:	89 04 24             	mov    %eax,(%esp)
  801ef7:	e8 f4 02 00 00       	call   8021f0 <nsipc_recv>
}
  801efc:	c9                   	leave  
  801efd:	c3                   	ret    

00801efe <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801efe:	55                   	push   %ebp
  801eff:	89 e5                	mov    %esp,%ebp
  801f01:	56                   	push   %esi
  801f02:	53                   	push   %ebx
  801f03:	83 ec 20             	sub    $0x20,%esp
  801f06:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801f08:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801f0b:	89 04 24             	mov    %eax,(%esp)
  801f0e:	e8 38 f5 ff ff       	call   80144b <fd_alloc>
  801f13:	89 c3                	mov    %eax,%ebx
  801f15:	85 c0                	test   %eax,%eax
  801f17:	78 21                	js     801f3a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801f19:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801f20:	00 
  801f21:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f24:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f28:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801f2f:	e8 c2 f3 ff ff       	call   8012f6 <sys_page_alloc>
  801f34:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801f36:	85 c0                	test   %eax,%eax
  801f38:	79 0a                	jns    801f44 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801f3a:	89 34 24             	mov    %esi,(%esp)
  801f3d:	e8 ff 01 00 00       	call   802141 <nsipc_close>
		return r;
  801f42:	eb 28                	jmp    801f6c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801f44:	8b 15 20 70 80 00    	mov    0x807020,%edx
  801f4a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f4d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801f4f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f52:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801f59:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f5c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801f5f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f62:	89 04 24             	mov    %eax,(%esp)
  801f65:	e8 b6 f4 ff ff       	call   801420 <fd2num>
  801f6a:	89 c3                	mov    %eax,%ebx
}
  801f6c:	89 d8                	mov    %ebx,%eax
  801f6e:	83 c4 20             	add    $0x20,%esp
  801f71:	5b                   	pop    %ebx
  801f72:	5e                   	pop    %esi
  801f73:	5d                   	pop    %ebp
  801f74:	c3                   	ret    

00801f75 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801f75:	55                   	push   %ebp
  801f76:	89 e5                	mov    %esp,%ebp
  801f78:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  801f7b:	8b 45 10             	mov    0x10(%ebp),%eax
  801f7e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f82:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f85:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f89:	8b 45 08             	mov    0x8(%ebp),%eax
  801f8c:	89 04 24             	mov    %eax,(%esp)
  801f8f:	e8 61 01 00 00       	call   8020f5 <nsipc_socket>
  801f94:	85 c0                	test   %eax,%eax
  801f96:	78 05                	js     801f9d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801f98:	e8 61 ff ff ff       	call   801efe <alloc_sockfd>
}
  801f9d:	c9                   	leave  
  801f9e:	66 90                	xchg   %ax,%ax
  801fa0:	c3                   	ret    

00801fa1 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  801fa1:	55                   	push   %ebp
  801fa2:	89 e5                	mov    %esp,%ebp
  801fa4:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  801fa7:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801faa:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fae:	89 04 24             	mov    %eax,(%esp)
  801fb1:	e8 07 f5 ff ff       	call   8014bd <fd_lookup>
  801fb6:	85 c0                	test   %eax,%eax
  801fb8:	78 15                	js     801fcf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  801fba:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801fbd:	8b 0a                	mov    (%edx),%ecx
  801fbf:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801fc4:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  801fca:	75 03                	jne    801fcf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  801fcc:	8b 42 0c             	mov    0xc(%edx),%eax
}
  801fcf:	c9                   	leave  
  801fd0:	c3                   	ret    

00801fd1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  801fd1:	55                   	push   %ebp
  801fd2:	89 e5                	mov    %esp,%ebp
  801fd4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801fd7:	8b 45 08             	mov    0x8(%ebp),%eax
  801fda:	e8 c2 ff ff ff       	call   801fa1 <fd2sockid>
  801fdf:	85 c0                	test   %eax,%eax
  801fe1:	78 0f                	js     801ff2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  801fe3:	8b 55 0c             	mov    0xc(%ebp),%edx
  801fe6:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fea:	89 04 24             	mov    %eax,(%esp)
  801fed:	e8 2d 01 00 00       	call   80211f <nsipc_listen>
}
  801ff2:	c9                   	leave  
  801ff3:	c3                   	ret    

00801ff4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801ff4:	55                   	push   %ebp
  801ff5:	89 e5                	mov    %esp,%ebp
  801ff7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801ffa:	8b 45 08             	mov    0x8(%ebp),%eax
  801ffd:	e8 9f ff ff ff       	call   801fa1 <fd2sockid>
  802002:	85 c0                	test   %eax,%eax
  802004:	78 16                	js     80201c <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  802006:	8b 55 10             	mov    0x10(%ebp),%edx
  802009:	89 54 24 08          	mov    %edx,0x8(%esp)
  80200d:	8b 55 0c             	mov    0xc(%ebp),%edx
  802010:	89 54 24 04          	mov    %edx,0x4(%esp)
  802014:	89 04 24             	mov    %eax,(%esp)
  802017:	e8 54 02 00 00       	call   802270 <nsipc_connect>
}
  80201c:	c9                   	leave  
  80201d:	c3                   	ret    

0080201e <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  80201e:	55                   	push   %ebp
  80201f:	89 e5                	mov    %esp,%ebp
  802021:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802024:	8b 45 08             	mov    0x8(%ebp),%eax
  802027:	e8 75 ff ff ff       	call   801fa1 <fd2sockid>
  80202c:	85 c0                	test   %eax,%eax
  80202e:	78 0f                	js     80203f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802030:	8b 55 0c             	mov    0xc(%ebp),%edx
  802033:	89 54 24 04          	mov    %edx,0x4(%esp)
  802037:	89 04 24             	mov    %eax,(%esp)
  80203a:	e8 1c 01 00 00       	call   80215b <nsipc_shutdown>
}
  80203f:	c9                   	leave  
  802040:	c3                   	ret    

00802041 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802041:	55                   	push   %ebp
  802042:	89 e5                	mov    %esp,%ebp
  802044:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802047:	8b 45 08             	mov    0x8(%ebp),%eax
  80204a:	e8 52 ff ff ff       	call   801fa1 <fd2sockid>
  80204f:	85 c0                	test   %eax,%eax
  802051:	78 16                	js     802069 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802053:	8b 55 10             	mov    0x10(%ebp),%edx
  802056:	89 54 24 08          	mov    %edx,0x8(%esp)
  80205a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80205d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802061:	89 04 24             	mov    %eax,(%esp)
  802064:	e8 46 02 00 00       	call   8022af <nsipc_bind>
}
  802069:	c9                   	leave  
  80206a:	c3                   	ret    

0080206b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80206b:	55                   	push   %ebp
  80206c:	89 e5                	mov    %esp,%ebp
  80206e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802071:	8b 45 08             	mov    0x8(%ebp),%eax
  802074:	e8 28 ff ff ff       	call   801fa1 <fd2sockid>
  802079:	85 c0                	test   %eax,%eax
  80207b:	78 1f                	js     80209c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80207d:	8b 55 10             	mov    0x10(%ebp),%edx
  802080:	89 54 24 08          	mov    %edx,0x8(%esp)
  802084:	8b 55 0c             	mov    0xc(%ebp),%edx
  802087:	89 54 24 04          	mov    %edx,0x4(%esp)
  80208b:	89 04 24             	mov    %eax,(%esp)
  80208e:	e8 5b 02 00 00       	call   8022ee <nsipc_accept>
  802093:	85 c0                	test   %eax,%eax
  802095:	78 05                	js     80209c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802097:	e8 62 fe ff ff       	call   801efe <alloc_sockfd>
}
  80209c:	c9                   	leave  
  80209d:	8d 76 00             	lea    0x0(%esi),%esi
  8020a0:	c3                   	ret    
	...

008020b0 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  8020b0:	55                   	push   %ebp
  8020b1:	89 e5                	mov    %esp,%ebp
  8020b3:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  8020b6:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  8020bc:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  8020c3:	00 
  8020c4:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  8020cb:	00 
  8020cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020d0:	89 14 24             	mov    %edx,(%esp)
  8020d3:	e8 18 08 00 00       	call   8028f0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  8020d8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8020df:	00 
  8020e0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8020e7:	00 
  8020e8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8020eb:	89 04 24             	mov    %eax,(%esp)
  8020ee:	e8 6f 08 00 00       	call   802962 <ipc_recv>
    return r;
}
  8020f3:	c9                   	leave  
  8020f4:	c3                   	ret    

008020f5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  8020f5:	55                   	push   %ebp
  8020f6:	89 e5                	mov    %esp,%ebp
  8020f8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  8020fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8020fe:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  802103:	8b 45 0c             	mov    0xc(%ebp),%eax
  802106:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  80210b:	8b 45 10             	mov    0x10(%ebp),%eax
  80210e:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  802113:	b8 09 00 00 00       	mov    $0x9,%eax
  802118:	e8 93 ff ff ff       	call   8020b0 <nsipc>
}
  80211d:	c9                   	leave  
  80211e:	c3                   	ret    

0080211f <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  80211f:	55                   	push   %ebp
  802120:	89 e5                	mov    %esp,%ebp
  802122:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  802125:	8b 45 08             	mov    0x8(%ebp),%eax
  802128:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  80212d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802130:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802135:	b8 06 00 00 00       	mov    $0x6,%eax
  80213a:	e8 71 ff ff ff       	call   8020b0 <nsipc>
}
  80213f:	c9                   	leave  
  802140:	c3                   	ret    

00802141 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802141:	55                   	push   %ebp
  802142:	89 e5                	mov    %esp,%ebp
  802144:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802147:	8b 45 08             	mov    0x8(%ebp),%eax
  80214a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80214f:	b8 04 00 00 00       	mov    $0x4,%eax
  802154:	e8 57 ff ff ff       	call   8020b0 <nsipc>
}
  802159:	c9                   	leave  
  80215a:	c3                   	ret    

0080215b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80215b:	55                   	push   %ebp
  80215c:	89 e5                	mov    %esp,%ebp
  80215e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802161:	8b 45 08             	mov    0x8(%ebp),%eax
  802164:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802169:	8b 45 0c             	mov    0xc(%ebp),%eax
  80216c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802171:	b8 03 00 00 00       	mov    $0x3,%eax
  802176:	e8 35 ff ff ff       	call   8020b0 <nsipc>
}
  80217b:	c9                   	leave  
  80217c:	c3                   	ret    

0080217d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80217d:	55                   	push   %ebp
  80217e:	89 e5                	mov    %esp,%ebp
  802180:	53                   	push   %ebx
  802181:	83 ec 14             	sub    $0x14,%esp
  802184:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802187:	8b 45 08             	mov    0x8(%ebp),%eax
  80218a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80218f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802195:	7e 24                	jle    8021bb <nsipc_send+0x3e>
  802197:	c7 44 24 0c 14 31 80 	movl   $0x803114,0xc(%esp)
  80219e:	00 
  80219f:	c7 44 24 08 20 31 80 	movl   $0x803120,0x8(%esp)
  8021a6:	00 
  8021a7:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  8021ae:	00 
  8021af:	c7 04 24 35 31 80 00 	movl   $0x803135,(%esp)
  8021b6:	e8 45 e2 ff ff       	call   800400 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  8021bb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8021bf:	8b 45 0c             	mov    0xc(%ebp),%eax
  8021c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021c6:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  8021cd:	e8 83 eb ff ff       	call   800d55 <memmove>
	nsipcbuf.send.req_size = size;
  8021d2:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  8021d8:	8b 45 14             	mov    0x14(%ebp),%eax
  8021db:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  8021e0:	b8 08 00 00 00       	mov    $0x8,%eax
  8021e5:	e8 c6 fe ff ff       	call   8020b0 <nsipc>
}
  8021ea:	83 c4 14             	add    $0x14,%esp
  8021ed:	5b                   	pop    %ebx
  8021ee:	5d                   	pop    %ebp
  8021ef:	c3                   	ret    

008021f0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  8021f0:	55                   	push   %ebp
  8021f1:	89 e5                	mov    %esp,%ebp
  8021f3:	56                   	push   %esi
  8021f4:	53                   	push   %ebx
  8021f5:	83 ec 10             	sub    $0x10,%esp
  8021f8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  8021fb:	8b 45 08             	mov    0x8(%ebp),%eax
  8021fe:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  802203:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  802209:	8b 45 14             	mov    0x14(%ebp),%eax
  80220c:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  802211:	b8 07 00 00 00       	mov    $0x7,%eax
  802216:	e8 95 fe ff ff       	call   8020b0 <nsipc>
  80221b:	89 c3                	mov    %eax,%ebx
  80221d:	85 c0                	test   %eax,%eax
  80221f:	78 46                	js     802267 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802221:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802226:	7f 04                	jg     80222c <nsipc_recv+0x3c>
  802228:	39 c6                	cmp    %eax,%esi
  80222a:	7d 24                	jge    802250 <nsipc_recv+0x60>
  80222c:	c7 44 24 0c 41 31 80 	movl   $0x803141,0xc(%esp)
  802233:	00 
  802234:	c7 44 24 08 20 31 80 	movl   $0x803120,0x8(%esp)
  80223b:	00 
  80223c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802243:	00 
  802244:	c7 04 24 35 31 80 00 	movl   $0x803135,(%esp)
  80224b:	e8 b0 e1 ff ff       	call   800400 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802250:	89 44 24 08          	mov    %eax,0x8(%esp)
  802254:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80225b:	00 
  80225c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80225f:	89 04 24             	mov    %eax,(%esp)
  802262:	e8 ee ea ff ff       	call   800d55 <memmove>
	}

	return r;
}
  802267:	89 d8                	mov    %ebx,%eax
  802269:	83 c4 10             	add    $0x10,%esp
  80226c:	5b                   	pop    %ebx
  80226d:	5e                   	pop    %esi
  80226e:	5d                   	pop    %ebp
  80226f:	c3                   	ret    

00802270 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802270:	55                   	push   %ebp
  802271:	89 e5                	mov    %esp,%ebp
  802273:	53                   	push   %ebx
  802274:	83 ec 14             	sub    $0x14,%esp
  802277:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80227a:	8b 45 08             	mov    0x8(%ebp),%eax
  80227d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802282:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802286:	8b 45 0c             	mov    0xc(%ebp),%eax
  802289:	89 44 24 04          	mov    %eax,0x4(%esp)
  80228d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802294:	e8 bc ea ff ff       	call   800d55 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802299:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  80229f:	b8 05 00 00 00       	mov    $0x5,%eax
  8022a4:	e8 07 fe ff ff       	call   8020b0 <nsipc>
}
  8022a9:	83 c4 14             	add    $0x14,%esp
  8022ac:	5b                   	pop    %ebx
  8022ad:	5d                   	pop    %ebp
  8022ae:	c3                   	ret    

008022af <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  8022af:	55                   	push   %ebp
  8022b0:	89 e5                	mov    %esp,%ebp
  8022b2:	53                   	push   %ebx
  8022b3:	83 ec 14             	sub    $0x14,%esp
  8022b6:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  8022b9:	8b 45 08             	mov    0x8(%ebp),%eax
  8022bc:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8022c1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8022c5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022c8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8022cc:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8022d3:	e8 7d ea ff ff       	call   800d55 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8022d8:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  8022de:	b8 02 00 00 00       	mov    $0x2,%eax
  8022e3:	e8 c8 fd ff ff       	call   8020b0 <nsipc>
}
  8022e8:	83 c4 14             	add    $0x14,%esp
  8022eb:	5b                   	pop    %ebx
  8022ec:	5d                   	pop    %ebp
  8022ed:	c3                   	ret    

008022ee <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8022ee:	55                   	push   %ebp
  8022ef:	89 e5                	mov    %esp,%ebp
  8022f1:	83 ec 18             	sub    $0x18,%esp
  8022f4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8022f7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8022fa:	8b 45 08             	mov    0x8(%ebp),%eax
  8022fd:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  802302:	b8 01 00 00 00       	mov    $0x1,%eax
  802307:	e8 a4 fd ff ff       	call   8020b0 <nsipc>
  80230c:	89 c3                	mov    %eax,%ebx
  80230e:	85 c0                	test   %eax,%eax
  802310:	78 25                	js     802337 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  802312:	be 10 60 80 00       	mov    $0x806010,%esi
  802317:	8b 06                	mov    (%esi),%eax
  802319:	89 44 24 08          	mov    %eax,0x8(%esp)
  80231d:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  802324:	00 
  802325:	8b 45 0c             	mov    0xc(%ebp),%eax
  802328:	89 04 24             	mov    %eax,(%esp)
  80232b:	e8 25 ea ff ff       	call   800d55 <memmove>
		*addrlen = ret->ret_addrlen;
  802330:	8b 16                	mov    (%esi),%edx
  802332:	8b 45 10             	mov    0x10(%ebp),%eax
  802335:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802337:	89 d8                	mov    %ebx,%eax
  802339:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80233c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80233f:	89 ec                	mov    %ebp,%esp
  802341:	5d                   	pop    %ebp
  802342:	c3                   	ret    
	...

00802350 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802350:	55                   	push   %ebp
  802351:	89 e5                	mov    %esp,%ebp
  802353:	83 ec 18             	sub    $0x18,%esp
  802356:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802359:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80235c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80235f:	8b 45 08             	mov    0x8(%ebp),%eax
  802362:	89 04 24             	mov    %eax,(%esp)
  802365:	e8 c6 f0 ff ff       	call   801430 <fd2data>
  80236a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80236c:	c7 44 24 04 56 31 80 	movl   $0x803156,0x4(%esp)
  802373:	00 
  802374:	89 34 24             	mov    %esi,(%esp)
  802377:	e8 1e e8 ff ff       	call   800b9a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80237c:	8b 43 04             	mov    0x4(%ebx),%eax
  80237f:	2b 03                	sub    (%ebx),%eax
  802381:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802387:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80238e:	00 00 00 
	stat->st_dev = &devpipe;
  802391:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  802398:	70 80 00 
	return 0;
}
  80239b:	b8 00 00 00 00       	mov    $0x0,%eax
  8023a0:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8023a3:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8023a6:	89 ec                	mov    %ebp,%esp
  8023a8:	5d                   	pop    %ebp
  8023a9:	c3                   	ret    

008023aa <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  8023aa:	55                   	push   %ebp
  8023ab:	89 e5                	mov    %esp,%ebp
  8023ad:	53                   	push   %ebx
  8023ae:	83 ec 14             	sub    $0x14,%esp
  8023b1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  8023b4:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8023b8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023bf:	e8 76 ee ff ff       	call   80123a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8023c4:	89 1c 24             	mov    %ebx,(%esp)
  8023c7:	e8 64 f0 ff ff       	call   801430 <fd2data>
  8023cc:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023d0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023d7:	e8 5e ee ff ff       	call   80123a <sys_page_unmap>
}
  8023dc:	83 c4 14             	add    $0x14,%esp
  8023df:	5b                   	pop    %ebx
  8023e0:	5d                   	pop    %ebp
  8023e1:	c3                   	ret    

008023e2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8023e2:	55                   	push   %ebp
  8023e3:	89 e5                	mov    %esp,%ebp
  8023e5:	57                   	push   %edi
  8023e6:	56                   	push   %esi
  8023e7:	53                   	push   %ebx
  8023e8:	83 ec 2c             	sub    $0x2c,%esp
  8023eb:	89 c7                	mov    %eax,%edi
  8023ed:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8023f0:	a1 80 74 80 00       	mov    0x807480,%eax
  8023f5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8023f8:	89 3c 24             	mov    %edi,(%esp)
  8023fb:	e8 b4 05 00 00       	call   8029b4 <pageref>
  802400:	89 c6                	mov    %eax,%esi
  802402:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802405:	89 04 24             	mov    %eax,(%esp)
  802408:	e8 a7 05 00 00       	call   8029b4 <pageref>
  80240d:	39 c6                	cmp    %eax,%esi
  80240f:	0f 94 c0             	sete   %al
  802412:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  802415:	8b 15 80 74 80 00    	mov    0x807480,%edx
  80241b:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  80241e:	39 cb                	cmp    %ecx,%ebx
  802420:	75 08                	jne    80242a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802422:	83 c4 2c             	add    $0x2c,%esp
  802425:	5b                   	pop    %ebx
  802426:	5e                   	pop    %esi
  802427:	5f                   	pop    %edi
  802428:	5d                   	pop    %ebp
  802429:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80242a:	83 f8 01             	cmp    $0x1,%eax
  80242d:	75 c1                	jne    8023f0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80242f:	8b 52 58             	mov    0x58(%edx),%edx
  802432:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802436:	89 54 24 08          	mov    %edx,0x8(%esp)
  80243a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80243e:	c7 04 24 5d 31 80 00 	movl   $0x80315d,(%esp)
  802445:	e8 7b e0 ff ff       	call   8004c5 <cprintf>
  80244a:	eb a4                	jmp    8023f0 <_pipeisclosed+0xe>

0080244c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80244c:	55                   	push   %ebp
  80244d:	89 e5                	mov    %esp,%ebp
  80244f:	57                   	push   %edi
  802450:	56                   	push   %esi
  802451:	53                   	push   %ebx
  802452:	83 ec 1c             	sub    $0x1c,%esp
  802455:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802458:	89 34 24             	mov    %esi,(%esp)
  80245b:	e8 d0 ef ff ff       	call   801430 <fd2data>
  802460:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802462:	bf 00 00 00 00       	mov    $0x0,%edi
  802467:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80246b:	75 54                	jne    8024c1 <devpipe_write+0x75>
  80246d:	eb 60                	jmp    8024cf <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80246f:	89 da                	mov    %ebx,%edx
  802471:	89 f0                	mov    %esi,%eax
  802473:	e8 6a ff ff ff       	call   8023e2 <_pipeisclosed>
  802478:	85 c0                	test   %eax,%eax
  80247a:	74 07                	je     802483 <devpipe_write+0x37>
  80247c:	b8 00 00 00 00       	mov    $0x0,%eax
  802481:	eb 53                	jmp    8024d6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802483:	90                   	nop
  802484:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802488:	e8 c8 ee ff ff       	call   801355 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80248d:	8b 43 04             	mov    0x4(%ebx),%eax
  802490:	8b 13                	mov    (%ebx),%edx
  802492:	83 c2 20             	add    $0x20,%edx
  802495:	39 d0                	cmp    %edx,%eax
  802497:	73 d6                	jae    80246f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802499:	89 c2                	mov    %eax,%edx
  80249b:	c1 fa 1f             	sar    $0x1f,%edx
  80249e:	c1 ea 1b             	shr    $0x1b,%edx
  8024a1:	01 d0                	add    %edx,%eax
  8024a3:	83 e0 1f             	and    $0x1f,%eax
  8024a6:	29 d0                	sub    %edx,%eax
  8024a8:	89 c2                	mov    %eax,%edx
  8024aa:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8024ad:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  8024b1:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  8024b5:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8024b9:	83 c7 01             	add    $0x1,%edi
  8024bc:	39 7d 10             	cmp    %edi,0x10(%ebp)
  8024bf:	76 13                	jbe    8024d4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8024c1:	8b 43 04             	mov    0x4(%ebx),%eax
  8024c4:	8b 13                	mov    (%ebx),%edx
  8024c6:	83 c2 20             	add    $0x20,%edx
  8024c9:	39 d0                	cmp    %edx,%eax
  8024cb:	73 a2                	jae    80246f <devpipe_write+0x23>
  8024cd:	eb ca                	jmp    802499 <devpipe_write+0x4d>
  8024cf:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8024d4:	89 f8                	mov    %edi,%eax
}
  8024d6:	83 c4 1c             	add    $0x1c,%esp
  8024d9:	5b                   	pop    %ebx
  8024da:	5e                   	pop    %esi
  8024db:	5f                   	pop    %edi
  8024dc:	5d                   	pop    %ebp
  8024dd:	c3                   	ret    

008024de <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8024de:	55                   	push   %ebp
  8024df:	89 e5                	mov    %esp,%ebp
  8024e1:	83 ec 28             	sub    $0x28,%esp
  8024e4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8024e7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8024ea:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8024ed:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8024f0:	89 3c 24             	mov    %edi,(%esp)
  8024f3:	e8 38 ef ff ff       	call   801430 <fd2data>
  8024f8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8024fa:	be 00 00 00 00       	mov    $0x0,%esi
  8024ff:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802503:	75 4c                	jne    802551 <devpipe_read+0x73>
  802505:	eb 5b                	jmp    802562 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  802507:	89 f0                	mov    %esi,%eax
  802509:	eb 5e                	jmp    802569 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  80250b:	89 da                	mov    %ebx,%edx
  80250d:	89 f8                	mov    %edi,%eax
  80250f:	90                   	nop
  802510:	e8 cd fe ff ff       	call   8023e2 <_pipeisclosed>
  802515:	85 c0                	test   %eax,%eax
  802517:	74 07                	je     802520 <devpipe_read+0x42>
  802519:	b8 00 00 00 00       	mov    $0x0,%eax
  80251e:	eb 49                	jmp    802569 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802520:	e8 30 ee ff ff       	call   801355 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802525:	8b 03                	mov    (%ebx),%eax
  802527:	3b 43 04             	cmp    0x4(%ebx),%eax
  80252a:	74 df                	je     80250b <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80252c:	89 c2                	mov    %eax,%edx
  80252e:	c1 fa 1f             	sar    $0x1f,%edx
  802531:	c1 ea 1b             	shr    $0x1b,%edx
  802534:	01 d0                	add    %edx,%eax
  802536:	83 e0 1f             	and    $0x1f,%eax
  802539:	29 d0                	sub    %edx,%eax
  80253b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802540:	8b 55 0c             	mov    0xc(%ebp),%edx
  802543:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802546:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802549:	83 c6 01             	add    $0x1,%esi
  80254c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80254f:	76 16                	jbe    802567 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802551:	8b 03                	mov    (%ebx),%eax
  802553:	3b 43 04             	cmp    0x4(%ebx),%eax
  802556:	75 d4                	jne    80252c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802558:	85 f6                	test   %esi,%esi
  80255a:	75 ab                	jne    802507 <devpipe_read+0x29>
  80255c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802560:	eb a9                	jmp    80250b <devpipe_read+0x2d>
  802562:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802567:	89 f0                	mov    %esi,%eax
}
  802569:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80256c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80256f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802572:	89 ec                	mov    %ebp,%esp
  802574:	5d                   	pop    %ebp
  802575:	c3                   	ret    

00802576 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802576:	55                   	push   %ebp
  802577:	89 e5                	mov    %esp,%ebp
  802579:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80257c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80257f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802583:	8b 45 08             	mov    0x8(%ebp),%eax
  802586:	89 04 24             	mov    %eax,(%esp)
  802589:	e8 2f ef ff ff       	call   8014bd <fd_lookup>
  80258e:	85 c0                	test   %eax,%eax
  802590:	78 15                	js     8025a7 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802592:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802595:	89 04 24             	mov    %eax,(%esp)
  802598:	e8 93 ee ff ff       	call   801430 <fd2data>
	return _pipeisclosed(fd, p);
  80259d:	89 c2                	mov    %eax,%edx
  80259f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8025a2:	e8 3b fe ff ff       	call   8023e2 <_pipeisclosed>
}
  8025a7:	c9                   	leave  
  8025a8:	c3                   	ret    

008025a9 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  8025a9:	55                   	push   %ebp
  8025aa:	89 e5                	mov    %esp,%ebp
  8025ac:	83 ec 48             	sub    $0x48,%esp
  8025af:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8025b2:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8025b5:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8025b8:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8025bb:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  8025be:	89 04 24             	mov    %eax,(%esp)
  8025c1:	e8 85 ee ff ff       	call   80144b <fd_alloc>
  8025c6:	89 c3                	mov    %eax,%ebx
  8025c8:	85 c0                	test   %eax,%eax
  8025ca:	0f 88 42 01 00 00    	js     802712 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8025d0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8025d7:	00 
  8025d8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8025db:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025df:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025e6:	e8 0b ed ff ff       	call   8012f6 <sys_page_alloc>
  8025eb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8025ed:	85 c0                	test   %eax,%eax
  8025ef:	0f 88 1d 01 00 00    	js     802712 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8025f5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8025f8:	89 04 24             	mov    %eax,(%esp)
  8025fb:	e8 4b ee ff ff       	call   80144b <fd_alloc>
  802600:	89 c3                	mov    %eax,%ebx
  802602:	85 c0                	test   %eax,%eax
  802604:	0f 88 f5 00 00 00    	js     8026ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80260a:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802611:	00 
  802612:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802615:	89 44 24 04          	mov    %eax,0x4(%esp)
  802619:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802620:	e8 d1 ec ff ff       	call   8012f6 <sys_page_alloc>
  802625:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802627:	85 c0                	test   %eax,%eax
  802629:	0f 88 d0 00 00 00    	js     8026ff <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80262f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802632:	89 04 24             	mov    %eax,(%esp)
  802635:	e8 f6 ed ff ff       	call   801430 <fd2data>
  80263a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80263c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802643:	00 
  802644:	89 44 24 04          	mov    %eax,0x4(%esp)
  802648:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80264f:	e8 a2 ec ff ff       	call   8012f6 <sys_page_alloc>
  802654:	89 c3                	mov    %eax,%ebx
  802656:	85 c0                	test   %eax,%eax
  802658:	0f 88 8e 00 00 00    	js     8026ec <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80265e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802661:	89 04 24             	mov    %eax,(%esp)
  802664:	e8 c7 ed ff ff       	call   801430 <fd2data>
  802669:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802670:	00 
  802671:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802675:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80267c:	00 
  80267d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802681:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802688:	e8 0b ec ff ff       	call   801298 <sys_page_map>
  80268d:	89 c3                	mov    %eax,%ebx
  80268f:	85 c0                	test   %eax,%eax
  802691:	78 49                	js     8026dc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802693:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802698:	8b 08                	mov    (%eax),%ecx
  80269a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80269d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80269f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  8026a2:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  8026a9:	8b 10                	mov    (%eax),%edx
  8026ab:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026ae:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  8026b0:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026b3:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  8026ba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8026bd:	89 04 24             	mov    %eax,(%esp)
  8026c0:	e8 5b ed ff ff       	call   801420 <fd2num>
  8026c5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8026c7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026ca:	89 04 24             	mov    %eax,(%esp)
  8026cd:	e8 4e ed ff ff       	call   801420 <fd2num>
  8026d2:	89 47 04             	mov    %eax,0x4(%edi)
  8026d5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8026da:	eb 36                	jmp    802712 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8026dc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8026e0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026e7:	e8 4e eb ff ff       	call   80123a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8026ec:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026ef:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026f3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026fa:	e8 3b eb ff ff       	call   80123a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8026ff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802702:	89 44 24 04          	mov    %eax,0x4(%esp)
  802706:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80270d:	e8 28 eb ff ff       	call   80123a <sys_page_unmap>
    err:
	return r;
}
  802712:	89 d8                	mov    %ebx,%eax
  802714:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  802717:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80271a:	8b 7d fc             	mov    -0x4(%ebp),%edi
  80271d:	89 ec                	mov    %ebp,%esp
  80271f:	5d                   	pop    %ebp
  802720:	c3                   	ret    
	...

00802730 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802730:	55                   	push   %ebp
  802731:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802733:	b8 00 00 00 00       	mov    $0x0,%eax
  802738:	5d                   	pop    %ebp
  802739:	c3                   	ret    

0080273a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80273a:	55                   	push   %ebp
  80273b:	89 e5                	mov    %esp,%ebp
  80273d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802740:	c7 44 24 04 75 31 80 	movl   $0x803175,0x4(%esp)
  802747:	00 
  802748:	8b 45 0c             	mov    0xc(%ebp),%eax
  80274b:	89 04 24             	mov    %eax,(%esp)
  80274e:	e8 47 e4 ff ff       	call   800b9a <strcpy>
	return 0;
}
  802753:	b8 00 00 00 00       	mov    $0x0,%eax
  802758:	c9                   	leave  
  802759:	c3                   	ret    

0080275a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80275a:	55                   	push   %ebp
  80275b:	89 e5                	mov    %esp,%ebp
  80275d:	57                   	push   %edi
  80275e:	56                   	push   %esi
  80275f:	53                   	push   %ebx
  802760:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802766:	b8 00 00 00 00       	mov    $0x0,%eax
  80276b:	be 00 00 00 00       	mov    $0x0,%esi
  802770:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802774:	74 41                	je     8027b7 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802776:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80277c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80277f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802781:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802787:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80278c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80278f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802793:	03 45 0c             	add    0xc(%ebp),%eax
  802796:	89 44 24 04          	mov    %eax,0x4(%esp)
  80279a:	89 3c 24             	mov    %edi,(%esp)
  80279d:	e8 b3 e5 ff ff       	call   800d55 <memmove>
		sys_cputs(buf, m);
  8027a2:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8027a6:	89 3c 24             	mov    %edi,(%esp)
  8027a9:	e8 e2 e7 ff ff       	call   800f90 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  8027ae:	01 de                	add    %ebx,%esi
  8027b0:	89 f0                	mov    %esi,%eax
  8027b2:	3b 75 10             	cmp    0x10(%ebp),%esi
  8027b5:	72 c5                	jb     80277c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  8027b7:	89 f0                	mov    %esi,%eax
  8027b9:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  8027bf:	5b                   	pop    %ebx
  8027c0:	5e                   	pop    %esi
  8027c1:	5f                   	pop    %edi
  8027c2:	5d                   	pop    %ebp
  8027c3:	c3                   	ret    

008027c4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8027c4:	55                   	push   %ebp
  8027c5:	89 e5                	mov    %esp,%ebp
  8027c7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8027ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8027cd:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8027d0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8027d7:	00 
  8027d8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8027db:	89 04 24             	mov    %eax,(%esp)
  8027de:	e8 ad e7 ff ff       	call   800f90 <sys_cputs>
}
  8027e3:	c9                   	leave  
  8027e4:	c3                   	ret    

008027e5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8027e5:	55                   	push   %ebp
  8027e6:	89 e5                	mov    %esp,%ebp
  8027e8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8027eb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8027ef:	75 07                	jne    8027f8 <devcons_read+0x13>
  8027f1:	eb 2d                	jmp    802820 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8027f3:	e8 5d eb ff ff       	call   801355 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8027f8:	90                   	nop
  8027f9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  802800:	e8 57 e7 ff ff       	call   800f5c <sys_cgetc>
  802805:	85 c0                	test   %eax,%eax
  802807:	74 ea                	je     8027f3 <devcons_read+0xe>
  802809:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  80280b:	85 c0                	test   %eax,%eax
  80280d:	78 16                	js     802825 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  80280f:	83 f8 04             	cmp    $0x4,%eax
  802812:	74 0c                	je     802820 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  802814:	8b 45 0c             	mov    0xc(%ebp),%eax
  802817:	88 10                	mov    %dl,(%eax)
  802819:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  80281e:	eb 05                	jmp    802825 <devcons_read+0x40>
  802820:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802825:	c9                   	leave  
  802826:	c3                   	ret    

00802827 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802827:	55                   	push   %ebp
  802828:	89 e5                	mov    %esp,%ebp
  80282a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80282d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802830:	89 04 24             	mov    %eax,(%esp)
  802833:	e8 13 ec ff ff       	call   80144b <fd_alloc>
  802838:	85 c0                	test   %eax,%eax
  80283a:	78 3f                	js     80287b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80283c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802843:	00 
  802844:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802847:	89 44 24 04          	mov    %eax,0x4(%esp)
  80284b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802852:	e8 9f ea ff ff       	call   8012f6 <sys_page_alloc>
  802857:	85 c0                	test   %eax,%eax
  802859:	78 20                	js     80287b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80285b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802861:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802864:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802866:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802869:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802870:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802873:	89 04 24             	mov    %eax,(%esp)
  802876:	e8 a5 eb ff ff       	call   801420 <fd2num>
}
  80287b:	c9                   	leave  
  80287c:	c3                   	ret    

0080287d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80287d:	55                   	push   %ebp
  80287e:	89 e5                	mov    %esp,%ebp
  802880:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802883:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802886:	89 44 24 04          	mov    %eax,0x4(%esp)
  80288a:	8b 45 08             	mov    0x8(%ebp),%eax
  80288d:	89 04 24             	mov    %eax,(%esp)
  802890:	e8 28 ec ff ff       	call   8014bd <fd_lookup>
  802895:	85 c0                	test   %eax,%eax
  802897:	78 11                	js     8028aa <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802899:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80289c:	8b 00                	mov    (%eax),%eax
  80289e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  8028a4:	0f 94 c0             	sete   %al
  8028a7:	0f b6 c0             	movzbl %al,%eax
}
  8028aa:	c9                   	leave  
  8028ab:	c3                   	ret    

008028ac <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  8028ac:	55                   	push   %ebp
  8028ad:	89 e5                	mov    %esp,%ebp
  8028af:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  8028b2:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  8028b9:	00 
  8028ba:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8028bd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028c1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8028c8:	e8 56 ee ff ff       	call   801723 <read>
	if (r < 0)
  8028cd:	85 c0                	test   %eax,%eax
  8028cf:	78 0f                	js     8028e0 <getchar+0x34>
		return r;
	if (r < 1)
  8028d1:	85 c0                	test   %eax,%eax
  8028d3:	7f 07                	jg     8028dc <getchar+0x30>
  8028d5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8028da:	eb 04                	jmp    8028e0 <getchar+0x34>
		return -E_EOF;
	return c;
  8028dc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8028e0:	c9                   	leave  
  8028e1:	c3                   	ret    
	...

008028f0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8028f0:	55                   	push   %ebp
  8028f1:	89 e5                	mov    %esp,%ebp
  8028f3:	57                   	push   %edi
  8028f4:	56                   	push   %esi
  8028f5:	53                   	push   %ebx
  8028f6:	83 ec 2c             	sub    $0x2c,%esp
  8028f9:	8b 75 08             	mov    0x8(%ebp),%esi
  8028fc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8028ff:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  802902:	85 db                	test   %ebx,%ebx
  802904:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  802909:	0f 45 c3             	cmovne %ebx,%eax
  80290c:	8b 55 14             	mov    0x14(%ebp),%edx
  80290f:	89 54 24 0c          	mov    %edx,0xc(%esp)
  802913:	89 44 24 08          	mov    %eax,0x8(%esp)
  802917:	89 7c 24 04          	mov    %edi,0x4(%esp)
  80291b:	89 34 24             	mov    %esi,(%esp)
  80291e:	e8 9d e7 ff ff       	call   8010c0 <sys_ipc_try_send>
  802923:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802926:	75 0a                	jne    802932 <ipc_send+0x42>
      sys_yield();
  802928:	e8 28 ea ff ff       	call   801355 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80292d:	8d 76 00             	lea    0x0(%esi),%esi
  802930:	eb d0                	jmp    802902 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802932:	85 c0                	test   %eax,%eax
  802934:	79 24                	jns    80295a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802936:	89 44 24 10          	mov    %eax,0x10(%esp)
  80293a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80293e:	c7 44 24 08 84 31 80 	movl   $0x803184,0x8(%esp)
  802945:	00 
  802946:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80294d:	00 
  80294e:	c7 04 24 a8 31 80 00 	movl   $0x8031a8,(%esp)
  802955:	e8 a6 da ff ff       	call   800400 <_panic>
    else
      return;
  }
}
  80295a:	83 c4 2c             	add    $0x2c,%esp
  80295d:	5b                   	pop    %ebx
  80295e:	5e                   	pop    %esi
  80295f:	5f                   	pop    %edi
  802960:	5d                   	pop    %ebp
  802961:	c3                   	ret    

00802962 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802962:	55                   	push   %ebp
  802963:	89 e5                	mov    %esp,%ebp
  802965:	56                   	push   %esi
  802966:	53                   	push   %ebx
  802967:	83 ec 10             	sub    $0x10,%esp
  80296a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80296d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802970:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802973:	85 c0                	test   %eax,%eax
  802975:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80297a:	0f 44 c2             	cmove  %edx,%eax
  80297d:	89 04 24             	mov    %eax,(%esp)
  802980:	e8 de e6 ff ff       	call   801063 <sys_ipc_recv>
  802985:	85 c0                	test   %eax,%eax
  802987:	78 24                	js     8029ad <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802989:	85 db                	test   %ebx,%ebx
  80298b:	74 0a                	je     802997 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  80298d:	a1 80 74 80 00       	mov    0x807480,%eax
  802992:	8b 40 74             	mov    0x74(%eax),%eax
  802995:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802997:	85 f6                	test   %esi,%esi
  802999:	74 0a                	je     8029a5 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  80299b:	a1 80 74 80 00       	mov    0x807480,%eax
  8029a0:	8b 40 78             	mov    0x78(%eax),%eax
  8029a3:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  8029a5:	a1 80 74 80 00       	mov    0x807480,%eax
  8029aa:	8b 40 70             	mov    0x70(%eax),%eax
}
  8029ad:	83 c4 10             	add    $0x10,%esp
  8029b0:	5b                   	pop    %ebx
  8029b1:	5e                   	pop    %esi
  8029b2:	5d                   	pop    %ebp
  8029b3:	c3                   	ret    

008029b4 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  8029b4:	55                   	push   %ebp
  8029b5:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  8029b7:	8b 45 08             	mov    0x8(%ebp),%eax
  8029ba:	89 c2                	mov    %eax,%edx
  8029bc:	c1 ea 16             	shr    $0x16,%edx
  8029bf:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8029c6:	f6 c2 01             	test   $0x1,%dl
  8029c9:	74 26                	je     8029f1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  8029cb:	c1 e8 0c             	shr    $0xc,%eax
  8029ce:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8029d5:	a8 01                	test   $0x1,%al
  8029d7:	74 18                	je     8029f1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  8029d9:	c1 e8 0c             	shr    $0xc,%eax
  8029dc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  8029df:	c1 e2 02             	shl    $0x2,%edx
  8029e2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  8029e7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  8029ec:	0f b7 c0             	movzwl %ax,%eax
  8029ef:	eb 05                	jmp    8029f6 <pageref+0x42>
  8029f1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8029f6:	5d                   	pop    %ebp
  8029f7:	c3                   	ret    
	...

00802a00 <__udivdi3>:
  802a00:	55                   	push   %ebp
  802a01:	89 e5                	mov    %esp,%ebp
  802a03:	57                   	push   %edi
  802a04:	56                   	push   %esi
  802a05:	83 ec 10             	sub    $0x10,%esp
  802a08:	8b 45 14             	mov    0x14(%ebp),%eax
  802a0b:	8b 55 08             	mov    0x8(%ebp),%edx
  802a0e:	8b 75 10             	mov    0x10(%ebp),%esi
  802a11:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802a14:	85 c0                	test   %eax,%eax
  802a16:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802a19:	75 35                	jne    802a50 <__udivdi3+0x50>
  802a1b:	39 fe                	cmp    %edi,%esi
  802a1d:	77 61                	ja     802a80 <__udivdi3+0x80>
  802a1f:	85 f6                	test   %esi,%esi
  802a21:	75 0b                	jne    802a2e <__udivdi3+0x2e>
  802a23:	b8 01 00 00 00       	mov    $0x1,%eax
  802a28:	31 d2                	xor    %edx,%edx
  802a2a:	f7 f6                	div    %esi
  802a2c:	89 c6                	mov    %eax,%esi
  802a2e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802a31:	31 d2                	xor    %edx,%edx
  802a33:	89 f8                	mov    %edi,%eax
  802a35:	f7 f6                	div    %esi
  802a37:	89 c7                	mov    %eax,%edi
  802a39:	89 c8                	mov    %ecx,%eax
  802a3b:	f7 f6                	div    %esi
  802a3d:	89 c1                	mov    %eax,%ecx
  802a3f:	89 fa                	mov    %edi,%edx
  802a41:	89 c8                	mov    %ecx,%eax
  802a43:	83 c4 10             	add    $0x10,%esp
  802a46:	5e                   	pop    %esi
  802a47:	5f                   	pop    %edi
  802a48:	5d                   	pop    %ebp
  802a49:	c3                   	ret    
  802a4a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802a50:	39 f8                	cmp    %edi,%eax
  802a52:	77 1c                	ja     802a70 <__udivdi3+0x70>
  802a54:	0f bd d0             	bsr    %eax,%edx
  802a57:	83 f2 1f             	xor    $0x1f,%edx
  802a5a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802a5d:	75 39                	jne    802a98 <__udivdi3+0x98>
  802a5f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802a62:	0f 86 a0 00 00 00    	jbe    802b08 <__udivdi3+0x108>
  802a68:	39 f8                	cmp    %edi,%eax
  802a6a:	0f 82 98 00 00 00    	jb     802b08 <__udivdi3+0x108>
  802a70:	31 ff                	xor    %edi,%edi
  802a72:	31 c9                	xor    %ecx,%ecx
  802a74:	89 c8                	mov    %ecx,%eax
  802a76:	89 fa                	mov    %edi,%edx
  802a78:	83 c4 10             	add    $0x10,%esp
  802a7b:	5e                   	pop    %esi
  802a7c:	5f                   	pop    %edi
  802a7d:	5d                   	pop    %ebp
  802a7e:	c3                   	ret    
  802a7f:	90                   	nop
  802a80:	89 d1                	mov    %edx,%ecx
  802a82:	89 fa                	mov    %edi,%edx
  802a84:	89 c8                	mov    %ecx,%eax
  802a86:	31 ff                	xor    %edi,%edi
  802a88:	f7 f6                	div    %esi
  802a8a:	89 c1                	mov    %eax,%ecx
  802a8c:	89 fa                	mov    %edi,%edx
  802a8e:	89 c8                	mov    %ecx,%eax
  802a90:	83 c4 10             	add    $0x10,%esp
  802a93:	5e                   	pop    %esi
  802a94:	5f                   	pop    %edi
  802a95:	5d                   	pop    %ebp
  802a96:	c3                   	ret    
  802a97:	90                   	nop
  802a98:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802a9c:	89 f2                	mov    %esi,%edx
  802a9e:	d3 e0                	shl    %cl,%eax
  802aa0:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802aa3:	b8 20 00 00 00       	mov    $0x20,%eax
  802aa8:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802aab:	89 c1                	mov    %eax,%ecx
  802aad:	d3 ea                	shr    %cl,%edx
  802aaf:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ab3:	0b 55 ec             	or     -0x14(%ebp),%edx
  802ab6:	d3 e6                	shl    %cl,%esi
  802ab8:	89 c1                	mov    %eax,%ecx
  802aba:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802abd:	89 fe                	mov    %edi,%esi
  802abf:	d3 ee                	shr    %cl,%esi
  802ac1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802ac5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ac8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802acb:	d3 e7                	shl    %cl,%edi
  802acd:	89 c1                	mov    %eax,%ecx
  802acf:	d3 ea                	shr    %cl,%edx
  802ad1:	09 d7                	or     %edx,%edi
  802ad3:	89 f2                	mov    %esi,%edx
  802ad5:	89 f8                	mov    %edi,%eax
  802ad7:	f7 75 ec             	divl   -0x14(%ebp)
  802ada:	89 d6                	mov    %edx,%esi
  802adc:	89 c7                	mov    %eax,%edi
  802ade:	f7 65 e8             	mull   -0x18(%ebp)
  802ae1:	39 d6                	cmp    %edx,%esi
  802ae3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ae6:	72 30                	jb     802b18 <__udivdi3+0x118>
  802ae8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802aeb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802aef:	d3 e2                	shl    %cl,%edx
  802af1:	39 c2                	cmp    %eax,%edx
  802af3:	73 05                	jae    802afa <__udivdi3+0xfa>
  802af5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802af8:	74 1e                	je     802b18 <__udivdi3+0x118>
  802afa:	89 f9                	mov    %edi,%ecx
  802afc:	31 ff                	xor    %edi,%edi
  802afe:	e9 71 ff ff ff       	jmp    802a74 <__udivdi3+0x74>
  802b03:	90                   	nop
  802b04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802b08:	31 ff                	xor    %edi,%edi
  802b0a:	b9 01 00 00 00       	mov    $0x1,%ecx
  802b0f:	e9 60 ff ff ff       	jmp    802a74 <__udivdi3+0x74>
  802b14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802b18:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802b1b:	31 ff                	xor    %edi,%edi
  802b1d:	89 c8                	mov    %ecx,%eax
  802b1f:	89 fa                	mov    %edi,%edx
  802b21:	83 c4 10             	add    $0x10,%esp
  802b24:	5e                   	pop    %esi
  802b25:	5f                   	pop    %edi
  802b26:	5d                   	pop    %ebp
  802b27:	c3                   	ret    
	...

00802b30 <__umoddi3>:
  802b30:	55                   	push   %ebp
  802b31:	89 e5                	mov    %esp,%ebp
  802b33:	57                   	push   %edi
  802b34:	56                   	push   %esi
  802b35:	83 ec 20             	sub    $0x20,%esp
  802b38:	8b 55 14             	mov    0x14(%ebp),%edx
  802b3b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802b3e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802b41:	8b 75 0c             	mov    0xc(%ebp),%esi
  802b44:	85 d2                	test   %edx,%edx
  802b46:	89 c8                	mov    %ecx,%eax
  802b48:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802b4b:	75 13                	jne    802b60 <__umoddi3+0x30>
  802b4d:	39 f7                	cmp    %esi,%edi
  802b4f:	76 3f                	jbe    802b90 <__umoddi3+0x60>
  802b51:	89 f2                	mov    %esi,%edx
  802b53:	f7 f7                	div    %edi
  802b55:	89 d0                	mov    %edx,%eax
  802b57:	31 d2                	xor    %edx,%edx
  802b59:	83 c4 20             	add    $0x20,%esp
  802b5c:	5e                   	pop    %esi
  802b5d:	5f                   	pop    %edi
  802b5e:	5d                   	pop    %ebp
  802b5f:	c3                   	ret    
  802b60:	39 f2                	cmp    %esi,%edx
  802b62:	77 4c                	ja     802bb0 <__umoddi3+0x80>
  802b64:	0f bd ca             	bsr    %edx,%ecx
  802b67:	83 f1 1f             	xor    $0x1f,%ecx
  802b6a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802b6d:	75 51                	jne    802bc0 <__umoddi3+0x90>
  802b6f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802b72:	0f 87 e0 00 00 00    	ja     802c58 <__umoddi3+0x128>
  802b78:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b7b:	29 f8                	sub    %edi,%eax
  802b7d:	19 d6                	sbb    %edx,%esi
  802b7f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802b82:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802b85:	89 f2                	mov    %esi,%edx
  802b87:	83 c4 20             	add    $0x20,%esp
  802b8a:	5e                   	pop    %esi
  802b8b:	5f                   	pop    %edi
  802b8c:	5d                   	pop    %ebp
  802b8d:	c3                   	ret    
  802b8e:	66 90                	xchg   %ax,%ax
  802b90:	85 ff                	test   %edi,%edi
  802b92:	75 0b                	jne    802b9f <__umoddi3+0x6f>
  802b94:	b8 01 00 00 00       	mov    $0x1,%eax
  802b99:	31 d2                	xor    %edx,%edx
  802b9b:	f7 f7                	div    %edi
  802b9d:	89 c7                	mov    %eax,%edi
  802b9f:	89 f0                	mov    %esi,%eax
  802ba1:	31 d2                	xor    %edx,%edx
  802ba3:	f7 f7                	div    %edi
  802ba5:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802ba8:	f7 f7                	div    %edi
  802baa:	eb a9                	jmp    802b55 <__umoddi3+0x25>
  802bac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bb0:	89 c8                	mov    %ecx,%eax
  802bb2:	89 f2                	mov    %esi,%edx
  802bb4:	83 c4 20             	add    $0x20,%esp
  802bb7:	5e                   	pop    %esi
  802bb8:	5f                   	pop    %edi
  802bb9:	5d                   	pop    %ebp
  802bba:	c3                   	ret    
  802bbb:	90                   	nop
  802bbc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bc0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802bc4:	d3 e2                	shl    %cl,%edx
  802bc6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802bc9:	ba 20 00 00 00       	mov    $0x20,%edx
  802bce:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802bd1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802bd4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802bd8:	89 fa                	mov    %edi,%edx
  802bda:	d3 ea                	shr    %cl,%edx
  802bdc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802be0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802be3:	d3 e7                	shl    %cl,%edi
  802be5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802be9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802bec:	89 f2                	mov    %esi,%edx
  802bee:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802bf1:	89 c7                	mov    %eax,%edi
  802bf3:	d3 ea                	shr    %cl,%edx
  802bf5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802bf9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802bfc:	89 c2                	mov    %eax,%edx
  802bfe:	d3 e6                	shl    %cl,%esi
  802c00:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802c04:	d3 ea                	shr    %cl,%edx
  802c06:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802c0a:	09 d6                	or     %edx,%esi
  802c0c:	89 f0                	mov    %esi,%eax
  802c0e:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802c11:	d3 e7                	shl    %cl,%edi
  802c13:	89 f2                	mov    %esi,%edx
  802c15:	f7 75 f4             	divl   -0xc(%ebp)
  802c18:	89 d6                	mov    %edx,%esi
  802c1a:	f7 65 e8             	mull   -0x18(%ebp)
  802c1d:	39 d6                	cmp    %edx,%esi
  802c1f:	72 2b                	jb     802c4c <__umoddi3+0x11c>
  802c21:	39 c7                	cmp    %eax,%edi
  802c23:	72 23                	jb     802c48 <__umoddi3+0x118>
  802c25:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802c29:	29 c7                	sub    %eax,%edi
  802c2b:	19 d6                	sbb    %edx,%esi
  802c2d:	89 f0                	mov    %esi,%eax
  802c2f:	89 f2                	mov    %esi,%edx
  802c31:	d3 ef                	shr    %cl,%edi
  802c33:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802c37:	d3 e0                	shl    %cl,%eax
  802c39:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802c3d:	09 f8                	or     %edi,%eax
  802c3f:	d3 ea                	shr    %cl,%edx
  802c41:	83 c4 20             	add    $0x20,%esp
  802c44:	5e                   	pop    %esi
  802c45:	5f                   	pop    %edi
  802c46:	5d                   	pop    %ebp
  802c47:	c3                   	ret    
  802c48:	39 d6                	cmp    %edx,%esi
  802c4a:	75 d9                	jne    802c25 <__umoddi3+0xf5>
  802c4c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802c4f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802c52:	eb d1                	jmp    802c25 <__umoddi3+0xf5>
  802c54:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c58:	39 f2                	cmp    %esi,%edx
  802c5a:	0f 82 18 ff ff ff    	jb     802b78 <__umoddi3+0x48>
  802c60:	e9 1d ff ff ff       	jmp    802b82 <__umoddi3+0x52>
